Re: Bug with SDCC and in-line assembler labels?
- From: "Joe G \(Home\)" <joe.g@xxxxxxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 21:44:48 +1100
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.
.
- References:
- Bug with SDCC and in-line assembler labels?
- From: Desert Rat
- Bug with SDCC and in-line assembler labels?
- Prev by Date: Re: Wired/Wireless Alarm Systems
- Next by Date: Re: the setmode of EDK
- Previous by thread: Re: Bug with SDCC and in-line assembler labels?
- Next by thread: Need advice: want to enter the Embedded field
- Index(es):
Relevant Pages
|