Re: Bug with SDCC and in-line assembler labels?



PS... there are quite a few SDCC users on the www.8052.com forum.

JG

"Desert Rat" <rhunt@xxxxxxxxxxxxxxxxxx> wrote in message
news:1143735545.336541.79720@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
If you use in-line assembly language within a SDCC program, are you
limited to the types of labels you may use if the assembler code
branches?

As an example, the following "do-nothing" program compiles and
assembles just fine:

void main(void)
{
_asm
nop
nop
nop
_endasm;
}

The following program, with an assembler label and a jump instruction,
also compiles and assembles without error:

void main(void)
{
_asm
nop
alabel:
nop
ljmp alabel
nop
_endasm;
}

But this code, although it compiles just fine, generates an "undefined
symbol encountered during assembly" error:

void main(void)
{
char i;
if (i == 1)
{
_asm
nop
alabel:
nop
ljmp alabel
nop
_endasm;
}
}

The problem is that SDCC generates the ".asm" file with labels of the
form "0xxxx$:", where xxxx is some number. The "alabel" label creates
a barrier between code above it and code below it. The IF statement
generates code above "alabel" which references the compiler-generated
label below "alabel", and cannot find it.

If you change the program to use a label of the form "0xxxx$" it
compiles and assembles fine again:

void main(void)
{
char i;
if (i == 1)
{
_asm
nop
01000$:
nop
ljmp 01000$
nop
_endasm;
}
}

Is there a way around this problem? Interestingly enough, the SDCC
manual shows an example of in-line assembler with a "normal" label.



.



Relevant Pages

  • Bug with SDCC and in-line assembler labels?
    ... The following program, with an assembler label and a jump instruction, ... ljmp alabel ...
    (comp.arch.embedded)
  • Re: Bug with SDCC and in-line assembler labels?
    ... The following program, with an assembler label and a jump instruction, ... ljmp alabel ...
    (comp.arch.embedded)
  • Re: RosAsm is a broken pile of crap
    ... If there's no type information stored (ie, MyPoint is just a label), I guess the assembler would interpret "10" as a DWORD and "10.0" as a floating-point variable? ... feed it a DWORD and it could treat it as a FLOAT, ... When programming assembler, the programmer must know what her data are ment to represent. ...
    (alt.lang.asm)
  • Re: RosAsm - right click
    ... definitions of the same label (ie. macros can be overloaded depending ... As for incremental compilation we could divide the window into ... currently I have to generate a listing to be certain the macro is ... so as not to interfere with the user's typing if the assembler ...
    (alt.lang.asm)
  • Re: To C.
    ... to the member's label inside the structure ... relative offset of the data from the start of the structure... ... As NASM or any other "real assembler", as you like to put it, ... whatever strange syntax is accepted... ...
    (alt.lang.asm)