• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   1 Anonymous Users






Re: 我用asm30写了一个函数供C来调用,我要不要保护W0~W7呀?
#4
新會員
新會員


查看用戶資訊
多谢版主!!

發表於: 2008/1/10 12:08
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 我用asm30写了一个函数供C来调用,我要不要保护W0~W7呀?
#3
版主
版主


查看用戶資訊
還有,其實要寫個除法(32/16) 可以直接使用 C30 所提供的 Builtin Fucntion,詳細的功能跟項目可以參考 C30 Uuse's Guide (C:\Program Files\Microchip\MPLAB C30\docs) 的 Appendix B 哩,那裏提供了 所有 Biltin Function 包含利用 DSP 的加減乘除。

__builtin_divsd
Description
Computes the quotient num denA math error exception occurs if den
is zero
. Function arguments are signed, as is the function resultThe
command
-line option -Wconversions can be used to detect unexpected
sign conversions
.
Prototypeint __builtin_divsd(const long num, const int den);
Argumentnum numerator
den denominator
Return ValueReturns the signed integer value of the quotient num den.
Assembler Operator
Machine
Instruction
:

發表於: 2008/1/10 12:02
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 我用asm30写了一个函数供C来调用,我要不要保护W0~W7呀?
#2
版主
版主


查看用戶資訊
如果你在彙編裡有使用到任何一個 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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


我用asm30写了一个函数供C来调用,我要不要保护W0~W7呀?
#1
新會員
新會員


查看用戶資訊
我的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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------