Re: c18 問題
|
||||
---|---|---|---|---|
高級會員
|
Nop() 與 nop(); 因該不一樣吧!
Rrncf(RAND3); ??? Rrncf(?? RAND3); 型態?,輸出入? 先學好 TURBO C++ 或 Borland C++ 再學C18!! 基礎先打好!!
發表於: 2004/6/13 0:40
|
|||
|
Re: c18 問題
|
||||
---|---|---|---|---|
版主
|
從錯誤訊息中看出,該巨集指令需要三個參數。詳情請查:
MPLAB® C18 C COMPILER USER’S GUIDE。
發表於: 2004/6/14 10:36
|
|||
|
Re: c18 問題
|
||||
---|---|---|---|---|
版主
|
先看看 MPLAC C18 對一些 Macro 指令所做的一些定義 (PIC18F452.h)如下所示,
#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 } Nop( ),Clrwdt( ), Sleep( ) 可直接使用於C程式中,且不需加 入任何參數。 但旋轉的指令就必須依據組合語言的型態指定 unsigned char 型態的變數,儲存的目的地,Access Bank 等三種參數。所以正確的語法 為Rrncf(RAND3,1,0) // 旋轉後存回自己,並使用Access Bank 詳細說明如下: If dest is 0, the result is stored in WREG, and if dest is 1, the result is stored in var. If access is 0, the access bank will be selected, overriding the BSR value. If access is 1, then the bank will be selected as per the BSR value.
發表於: 2004/6/14 10:50
|
|||
|
Re: c18 問題
|
||||
---|---|---|---|---|
新會員
|
謝謝指導 void abc(void) { Rrncf(RAND3,1,0); } 可是以上的語法,在編譯時但又產生如下的錯誤訊息 Error [1253] constant operand expected Error [1253] constant operand expected
發表於: 2004/6/14 15:37
|
|||
san
|
||||
|
Re: c18 問題
|
||||
---|---|---|---|---|
高級會員
|
在C18裡的MACRO語法好像是使用IN LINE ASM的用法 , 運算元的用法應該只能使用常數 , 將你的變數RAND3先利定址宣告在特定位址 , 找到RAND3變數位址後 , 直接代入 , 應該就可以了 ,
假設變數宣告位址在0X20 Rrncf(0x20 , 1 , 0); 試試看吧 !
發表於: 2004/6/28 11:47
|
|||
|