Re: 我用asm30写了一个函数供C来调用,我要不要保护W0~W7呀?
|
||||
---|---|---|---|---|
新會員
|
多谢版主!!
發表於: 2008/1/10 12:08
|
|||
|
Re: 我用asm30写了一个函数供C来调用,我要不要保护W0~W7呀?
|
||||
---|---|---|---|---|
版主
|
如果你在彙編裡有使用到任何一個 W 暫存器的話建議是都把它佔存起來。一般在會編儘量只使用 W0 ~ W3 ,這樣只要用 PUSH S & POP S 就可以利用 Shadow Register 做最快速的存取。以下是 C call Assembly 的基本語法:
Assembly 利用 global 宣告 -- .section my_code, code .global _myfunction ; myfunction is externally visible ; and starts here! _myfunction: push s clr w0 : : pop s retfie 在 C 底下使用 extern 宣告: extern void myfunction(void); void main(void) { myfunction(); /* and so on */ }
發表於: 2008/1/10 11:55
|
|||
|
我用asm30写了一个函数供C来调用,我要不要保护W0~W7呀?
|
||||
---|---|---|---|---|
新會員
|
我的asm30程序如下,
;ulong Div32(ulong a,uint b) _Div32: push W3 push W4 mov W0,W3 mov W1,W0 repeat #17 div.u W0,W2 mov W0,W4 mov W3,W0 repeat #17 div.ud W0,W2 mov W4,W1 pop W4 pop W3 return 我进行push W3,push W4入栈操作,进行这些操作有必要吗? 如果这个函数被中断打断,原来的W寄存器的值会恢复原来的值呀?
發表於: 2008/1/9 21:02
|
|||
|