converting from C to 8051 Assembly Question

Thread Starter

eng.me

Joined Dec 10, 2012
27
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):
LCALL    ?C?LLDOPTR
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

tea_encryption_32round:
    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
    LCALL    ?C?ULCMP
    JC       $ + 5H
    LJMP     ?C0002
 

Ian Rogers

Joined Dec 12, 2012
1,136
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

eng.me

Joined Dec 10, 2012
27
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):
?C?LLDOPTR
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.
 
Top