Colin Wall schrieb:
gcc gererates a header in easch assembly output that looks like
.file "fifo.c"
.arch atmega168
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
.global __do_copy_data
.global __do_clear_bss
; GNU C version 3.4.6 (avr)
No, it does not exist in any header. It exists in gcc ;-)
Georg-Johann
So, from what I can see, the compiler makes these defines available to
C source, but not to asm (.S) source, and I need to repeat them myself
in the asm file to use them there.
No, these defines are not available in a C source. They are available in
a assembler .s source that is generated by the compiler.
So you can use this in your inline asm.
If you like make you can make the assembler source(s) dependent on a
dummy header:
.INTERMEDIATE: asm-defines.h dummy.c
%.S: asm-defines.h
dummy.c:
touch $<
asm-defines.h: dummy.c
avr-gcc -mmcu=$(MCU_TARGET) -S $< -o $@
and include the generated header in your files
#include "asm-defines.h"
in order to be always in sync with the compiler and the target.
You can make use of the constructions (examples):
out (_SFR_IO_ADDR(SREG)), r25
out (_SFR_IO_ADDR(SPL)), r26
out (_SFR_IO_ADDR(SPH)), r27
etc, if i remember correctly.
These work in the asm file because SREG etc are defined when io.h is
included. I can't see a way to use __tmp_reg__ et al without re-defining
them myself.
This is just an asm file head. You cannot use __SREG__ et al. without
redefining it or letting avr-gcc write a file like described above.
Note that SREG is different from __SREG__:
SREG from libc header expands to the RAM address.
__SREG__ from gcc output is set to the SFR address in I/O space.
Georg-Johann
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list