Re: XC8在巨集定義中使用\來換行時,如何加入#asm ... #endasm?
|
||||
---|---|---|---|---|
管理員
|
kimking你好,建議使用 asm("..."); 取代 #asm ... #endasm,目前在較新的 XC8 C Compiler 版本已不支援部份語法,詳細使用方式可以參考 MPLAB® XC8 C Compiler User’s Guide 的 2.5.16 In-line Assembly。
發表於: 2022/9/21 14:31
|
|||
|
XC8在巨集定義中使用\來換行時,如何加入#asm ... #endasm?
|
||||
---|---|---|---|---|
初級會員
|
系統及軟體版本:Windows 7 32位元、MPLAB X IDE v5.20、XC8 v2.05。
我想把用C18編譯的韌體移植到XC8, 在巨集定義中使用\來換行時, 若有#asm ... #endasm就會出現編譯錯誤, 於是寫了一個小的測試程式, 在main.c中 unsigned char i = 30, j = 9, k = 1; void main(void) { i = j + k; #asm movlw 0x64 #endasm asm("movlw 0x32"); _BLOCK1() _BLOCK2() while(1); } 在global.h中 extern unsigned char i, j, k; #define _BLOCK1()\ i = ( j - k ) * 2;\ #asm\ movlw 0x19\ nop\ #endasm #define _BLOCK2()\ i = ( j - k ) * 2;\ asm("movlw 0x19");\ asm("nop"); _BLOCK1()的部分編譯時會出問題, 個人猜測是\之後緊接著#asm或#endasm會無法辨識, 請問XC8在巨集定義中使用\來換行時, 如何加入#asm ... #endasm? 謝謝!
發表於: 2022/9/16 11:30
|
|||
|