« Return to Thread: loading a global variable (C) in assembly

Re: loading a global variable (C) in assembly

by Joerg Wunsch :: Rate this Message:

Reply to Author | View in Thread

"Daniel Otte" <daniel.otte@...> wrote:

> how can I reference (load) global variables which are declared in C
> code = in assembly code?

You just write the name of the variable:

lds r24, name_of_your_variable

If you want to be nice to the reader of your program, you declare
it external before:

..extern name_of_your_variable

However, that's not strictly necessary; any symbol the assembler
encounters it doesn't know about yet, it enters into the symbol table
as `undefined external'.  In effect, that's the same as the .extern
statement is going to do.

--
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)


_______________________________________________
AVR-chat mailing list
AVR-chat@...
http://lists.nongnu.org/mailman/listinfo/avr-chat

 « Return to Thread: loading a global variable (C) in assembly