Bug with SDCC and in-line assembler labels?
- From: "Desert Rat" <rhunt@xxxxxxxxxxxxxxxxxx>
- Date: 30 Mar 2006 08:19:05 -0800
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.
.
- Follow-Ups:
- Re: Bug with SDCC and in-line assembler labels?
- From: Joe G \(Home\)
- Re: Bug with SDCC and in-line assembler labels?
- From: Joe G \(Home\)
- Re: Bug with SDCC and in-line assembler labels?
- Prev by Date: Re: what kind of embedded os should i choose?
- Next by Date: Re: Weird 8051 assembler code generated by SDCC
- Previous by thread: Weird 8051 assembler code generated by SDCC
- Next by thread: Re: Bug with SDCC and in-line assembler labels?
- Index(es):
Relevant Pages
|