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


Browsing this Thread:   1 Anonymous Users




« 1 (2)


Re: 請問C語言中如何加入組語??
#9
初級會員
初級會員


查看用戶資訊
1.)請問板大,像下面的程式,我使用In-Line Assembly 的方式,為什麼還是編譯會有錯誤??是我In-Line Assembly用法錯誤了嗎?還是應該要再加入什麼??謝謝


void writeeeprom(void)
{
#asm
banksel EEADR;
movf DATA_EE_ADDR,W;
movwf EEADR;
movf DATA_EE_DATA,W;
movwf EEDATA;
banksel EECON1;
bcf EECON1,7,0;
bsf EECON1,2,0; bcf INTCON,1,0;
movlw 0x55;
movwf EECON2;
movlw 0xAA;
movwf EECON2;
bsf EECON1,1,0;
bsf INTCON,1,0;
bcf EECON1,2,0;
btfsc EECON1,1,0;
goto $-1

#endasm
}//

錯誤訊息如下:
Error [845] D:\pic_test\try_writeEEPROM\try_writeEEPROM.c; 25. symbol "banksel" defined more than once
Error [876] D:\pic_test\try_writeEEPROM\try_writeEEPROM.c; 27. syntax error
Error [876] D:\pic_test\try_writeEEPROM\try_writeEEPROM.c; 37. syntax error
Error [800] C:\DOCUME~1\thomasho\LOCALS~1\Temp\s4r8.; 250. undefined symbol "DATA_EE_ADDR"
Error [800] C:\DOCUME~1\thomasho\LOCALS~1\Temp\s4r8.; 256. undefined symbol "DATA_EE_DATA"
Error [800] C:\DOCUME~1\thomasho\LOCALS~1\Temp\s4r8.; 259. undefined symbol "EEDATA"
Error [800] C:\DOCUME~1\thomasho\LOCALS~1\Temp\s4r8.; 274. undefined symbol "EECON2"


2.)請問_asm與#asm用法有何不同?因為我使用出來錯誤訊息也不同,請板大解惑!!謝謝!!

發表於: 2008/9/23 15:31

Edited by fbs1107 on 2008年09月23日 16:02:19
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問C語言中如何加入組語??
#8
版主
版主


查看用戶資訊
C 呼叫組語是天經地義的事,但是要用此功能是要有些程度,初學著暫時不要考慮此問題。如果你對組語的 Glorbal & Extern 等架構不熟悉的話暫時不要去踢這個鐵板。先考慮使用 In-Line Assembly 吧!

發表於: 2008/9/23 11:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問C語言中如何加入組語??
#7
初級會員
初級會員


查看用戶資訊
那再請問板大,C語言中可以呼叫C的函式,那在C中可以呼叫asm的函式嗎??

發表於: 2008/9/23 10:47
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問C語言中如何加入組語??
#6
初級會員
初級會員


查看用戶資訊
感謝板大,小弟獲益良多!~~

發表於: 2008/9/23 10:16
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問C語言中如何加入組語??
#5
版主
版主


查看用戶資訊
void mystartupvoid )
{
     
PORTC 0x00;
     
TRISC 0x00;
 
#asm
     
clrf   _STATUS
     clrf   _PORTB
     bsf    _STATUS
,5
     clrf   _TRISB

     movlw   high start
     movwf   _PCLATH
     
goto   ( start 0x7FF ); asm “ljmp start“ );   
#endasm
}


嵌入式組語用 #asm 開始,#endasm 結束
使用的周邊名稱要在前面加上 _ 。

發表於: 2008/9/23 8:43
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請問C語言中如何加入組語??
#4
初級會員
初級會員


查看用戶資訊
請問各位前輩們,C語言中如何加入組語??小弟用的編譯器Hi-tech,晶片用16f883,我只知道可以用asm("nop"),這樣的用法!!如果說是要再C中加入一段組語,請問要如何用??謝謝

發表於: 2008/9/22 21:06
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... ]

教育訓練中心

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