converting from C to 8051 Assembly Question

Thread Starter

Joined Dec 10, 2012
Dear all;
I tried to convert C code of an encryption algorithm called TEA to 8051 assembly code using Keil assembler.
I found some string code line like the one bellow .
Rich (BB code):
the assembler called external function form C language.
Is this instruction correct or should I look what is this function do then convert the C function idea to 8051 assembly?

here is another example
the C code is
Rich (BB code):
for (i=0; i < 32; i++)
the assembly is
Rich (BB code):
CLR      A
    MOV      i?045+03H,A
    MOV      i?045+02H,A
    MOV      i?045+01H,A
    MOV      i?045,A

    CLR      A
    MOV      R7,#020H    ; 020h = 32 d
    MOV      R6,A
    MOV      R5,A
    MOV      R4,A
    MOV      R3,i?045+03H
    MOV      R2,i?045+02H
    MOV      R1,i?045+01H
    MOV      R0,i?045
    CLR      C
    JC       $ + 5H
    LJMP     ?C0002

Ian Rogers

Joined Dec 12, 2012
Its difficult to do what you want because external functions are not always easy to see

?C?ULCMP is Unsigned Long compare i < 32.

?C?LLOPTR seems to be a data pointer...

?ixxx is initialised data variable address.
?C seems to be code address.

Thread Starter

Joined Dec 10, 2012
Thank you Ian Rogers for your response.
What if I use this C external function in my 8051 assembly code as I got it from the assembler. Does this Function will work correctly?

By the way the code below has a meaning
Rich (BB code):
the meaning is
L : indicates a long that is passed in R4/R5/R6/R7.
LD : indicates a read (load) operation.
OPTR : represents a 3-byte pointer plus an offset in R1/R2/R3 + DPTR.