[英]Problems combining SDCC and ASM code compiling on the Intel 8051
我們正在嘗試編譯我們的C代碼,其中包括許多用於各種操作(定時,生成輸出波形和測量輸入頻率)的匯編。
我們的一些ASM操作不斷遇到相同的錯誤:
“ REL區域中的.org或指令/助記符錯誤”
在下面的代碼中,我們遇到3個錯誤(我評論了它們發生在哪幾行,以及我們得到的確切是什么錯誤。謝謝!
void getFrequency(int *freqHi, int *freqLo)
{
__asm
;
; A program that measures the frequency at pin T0 (P1.2)
ljmp GetFreq
Wait1s:
mov R2, #40
M3: mov R1, #250
M2: mov R0, #181
M1: djnz R0, M1 ; 2 machine cycles-> 2*0.27126us*181=100us
djnz R1, M2 ; 100us*250=0.025s
djnz R2, M3 ; 0.025s*40=1s
ret
;Initializes timer/counter 0 as a 16-bit counter
InitTimer0:
setb T0 ; Enable pin T0 as input
clr TR0 ; Stop timer 0
mov a,#0F0H ; ERROR <o> .org in REL area or directive / mnemonic error
anl a,TMOD
orl a,#00000101B ; Set timer 0 as 16-bit counter ERROR <o> .org in REL area or directive / mnemonic error
mov TMOD,a
ret
GetFreq:
mov SP, #7FH ; Set the stack pointer to the begining of idata ERROR <o> .org in REL area or directive / mnemonic error
lcall InitTimer0
clr TR0 ; Stop counter 0
mov TL0, #0
mov TH0, #0
setb TR0 ; Start counting
lcall Wait1s ; Wait one second
clr TR0 ; Stop counter 0, TH0-TL0 has the frequency
mov R0, TH0
mov R1, TL0
mov _freqHi, R0
mov _freqLo, R1
__endasm;
// freqHi, freqLo have respective values
}
sdcc
的匯編器不支持您正在使用的立即數的H
和B
后綴語法。
嘗試使用#0xF0
代替#0F0H
,以及#0b00000101
代替#00000101B
,等等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.