• slider image 442
  • slider image 497
  • slider image 498
  • slider image 499
  • slider image 500
  • slider image 502
:::


Browsing this Thread:   1 Anonymous Users






Re: 請教c語言如何寫出RLCF的功能
#4
資深會員
資深會員


查看用戶資訊
我用C是這樣寫的,讀進來的資料都先放在 bit0。
if(C)
  
data|=0x01;
else
  
data&=0xfe;
data<<=1;        //左移一位

發表於: 2008/12/29 11:58
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教c語言如何寫出RLCF的功能
#3
新會員
新會員


查看用戶資訊
用In-Line Assembly果然是最直接的,謝謝囉

發表於: 2008/12/26 15:35
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教c語言如何寫出RLCF的功能
#2
版主
版主


查看用戶資訊
最好是用 In-Line Assembly 的方式來寫這樣最直接。如果用 C 寫的話可以參考一下 p18f6520.h 檔裡對 RLCF 的巨集宣告及對STATUS 的宣告配合使用。
extern          near unsigned char       STATUS;
extern          near struct {
  
unsigned C:1;
  
unsigned DC:1;
  
unsigned Z:1;
  
unsigned OV:1;
  
unsigned N:1;
STATUSbits;
:
:
/*-------------------------------------------------------------------------
 * Some useful macros for inline assembly stuff
 *-------------------------------------------------------------------------*/
#define Nop()    {_asm nop _endasm}
#define ClrWdt() {_asm clrwdt _endasm}
#define Sleep()  {_asm sleep _endasm}
#define Reset()  {_asm reset _endasm}

#define Rlcf(f,dest,access)  {_asm movlb f rlcf f,dest,access _endasm}
#define Rlncf(f,dest,access) {_asm movlb f rlncf f,dest,access _endasm}
#define Rrcf(f,dest,access)  {_asm movlb f rrcf f,dest,access _endasm}
#define Rrncf(f,dest,access) {_asm movlb f rrncf f,dest,access _endasm}
#define Swapf(f,dest,access) {_asm movlb f swapf f,dest,access _endasm }


利用 RLCF 轉一個 unsigned char 到 C 後再將 STATUSbits.C 移到一個變數後再判斷,我不知道直接用 IF (STSTUSbits.C) 去判斷會不會事先就影響到 C 旗號,可能要看一下C的反組譯程式才會知道。

發表於: 2008/12/26 15:01
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請教c語言如何寫出RLCF的功能
#1
新會員
新會員


查看用戶資訊
如標題:
請問使用C語言要如何寫出含有C進位旗標的左移
uC使用18F6520,謝謝各位先輩

發表於: 2008/12/26 11:18
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... ]

教育訓練中心

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