Problems Compiling SDCC and ASM Code on Intel 8051

We are trying to compile our C-code, which includes an assembly for various operations (synchronization, generating output signals and measuring the input frequency).

We continue to get the same error for several of our ASM operations:

".org in REL or directory / mnemonic error"

In our code below we get 3 errors (I commented on which lines they occur and what exactly our error is. Thank you!

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
}
+3
source share
1 answer

sdccThe assembler does not support the syntax suffixes Hand Bfor immediate values that you use.

#0xF0 #0F0H #0b00000101 #00000101B ..

+2

Source: https://habr.com/ru/post/1792289/


All Articles