• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: XC8在巨集定義中使用\來換行時,如何加入#asm ... #endasm?
#3
初級會員
初級會員


查看用戶資訊
我在移植的韌體有很多巨集使用 _asm ... _endasm 結構,
除了逐行全部修改成 asm("..."); 有點費工之外,
有的巨集還包含其他巨集,
在asm("...");中需要額外使用___mkstr(巨集名)的方式去擴展。

才會把編譯器選項的C standard調為C90,
讓#asm ... #endasm結構可以繼續使用,
在巨集中卻會遇到問題無法編譯,
所以求助大家看是否能解決這個語法問題,
萬一不行只好用asm("...");慢慢搞。

感謝!

發表於: 2022/9/21 16:36
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: XC8在巨集定義中使用\來換行時,如何加入#asm ... #endasm?
#2
管理員
管理員


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


XC8在巨集定義中使用\來換行時,如何加入#asm ... #endasm?
#1
初級會員
初級會員


查看用戶資訊
系統及軟體版本: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
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... ]

教育訓練中心

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