On Mon, 2009-08-03 at 09:44 +0530, sumanth wrote:
>        How can i make sure my tool chain knows the difference between 
> global variable r0 and register r0.

The simple solution is to either add a prefix to variable names, or to
add a prefix to register names.  In ELF, the convention is to not add a
prefix to variables names, we add a prefix to register names instead if
we need one, e.g. %eax on i386, or $4 on mips.

You can of course choose to add a prefix to variable names.  It just
isn't the convention.  See for instance how the arm-elf port works when
you use the -fleading-underscore option.

A less simple solution is to have an assembler syntax that avoids
ambiguity between register names and variable names.  If for instance
you have a move instruction that can accept either a register or a
variable as source, then you have an ambiguity.  You could instead have
a load instruction for reading memory, and a move instruction for
reading registers, and then you don't have an ambiguity anymore.  You
can also do things with addressing modes and relocation operators to
reduce ambiguities.

Jim


Reply via email to