Maarten,

> > On a similar note, chapter 3.12 says on labels in inline assembler, that
"In
> > older versions of the compiler all labels defined within inline
assembler
> > code had to be of the form nnnnn$ where nnnn is a number less than 100
> > (which implies a limit of utmost 100 inline assembler labels per
function)."
> > OK, which is "older versions of compiler" and assuming I have the
up-to-date
> > version, what are the rules now?
>
> I don't know what "older versions" means. The label does
> not need to be of the form nnnnn$ but these are treated
> as local labels by the assembler. They can reoccur after
> any other label. The compiler will generate only local
> labels above 100 and so all <100 are at your disposal.
> If you need more you might need to rethink your
> implementation strategy.

I just thought on this further, looking here and there.
The "locality" of these labels is constrained in a rather strange way... but
useful, I admit... and it brings up several other questions:

- where does the compiler use non-local labels, which are the boundaries of
"locality"? I assume, it uses them _only_ on the function boundaries (and
for variables and constants and stuff like that, but I meant in the raw code
area). Correct? If yes, it would mean, that the locality of local labels is
constrained within a function.

- the example given in chapter 3.12 is incorrect then in two ways: the
compiler would not insert a non-local label ("clabel") inside a function,
and the $0003 label would not be viewed by the two parts of asm code as one
symbol, if clabel is in between.

- if I use an inline assembler function with non-local symbol, and if that
inline assembler would be inside a C function with C statements before and
after (e.g. within a loop), such a non-local symbol would break up the local
symbols which the compiler put inside the function. This is not a question
but a statement, I verified this. Whence, the "in older versions" shall be
removed and the statement is still very valid - the only safe "any label"
condition I am able to formulate concisely is, that the inline assembler
should be not surrounded by any C-statements in that function (although this
might be often the case, I admit).

- also, I'd reformulate "nnnnn$" which implies a 5-digit number (with
subsequent "nnnn" implying 4-digit number :-) ) into "n$, where n is a
positive decimal integer (with or without leading zeros), or something like
that

Just an anecdotal mention, the assembler's documentation says, the maximum
number ("nnnnn") of local symbols is 255. So I looked into the sources and
found this wonderful comment just at the right place:

/* sandeep changed to 'int' from 'char' */
/* this will increase the number temp symbols
   that can be defined from 255 to INT_MAX */

:-)

JW



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to