assemblykeilsdccc51

C51 C compiler inline assembly to SDCC inline assembly


I'm not very into assembly but for a project I have to modify a few lines of assembly code for the C51 C compiler to the SDCC.

This is code for C51

setb    T1Run
setb    T0Run

setb    IDLE
jnb     T0Full, $

Which, compiled with SDCC produces

?ASlink-Warning-Undefined Global 'IDLE' referenced by module 'Com_Func'

?ASlink-Warning-Undefined Global '$' referenced by module 'Com_Func'

?ASlink-Warning-Undefined Global 'T0Run' referenced by module 'Com_Func'

?ASlink-Warning-Undefined Global 'T1Run' referenced by module 'Com_Func'

?ASlink-Warning-Byte PCR relocation error for symbol  $
         file              module            area              offset
  Refby  ./Com_Func.rel    Com_Func          CSEG                     004A
  Defin  ./Com_Func.rel    Com_Func          CABS                     0000

as compiler errors/warnings.


Solution

  • I would think you could just replace the $ with a label defined on the same line.

    00001$: 
      jnb     T0Full, 00001$
    

    Note that according to the SDCC Compiler User Guide:

    All labels defined within inline assembler code have to be of the form nnnnn$ where nnnnn is a number less than 100 (which implies a limit of utmost 100 inline assembler labels per function).

    As for the other compiler warnings, those are symbols that assumedly haven't been defined anywhere. How were they defined in the original C51 code?