|
From: | Georg-Johann Lay |
Subject: | Re: [avr-gcc-list] Using __tmp_reg__ etc in assembly file |
Date: | Fri, 23 Jan 2009 01:06:01 +0100 |
User-agent: | Mozilla Thunderbird 1.0.7 (Windows/20050923) |
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-JohannSo, 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.
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-definingYou 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.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
[Prev in Thread] | Current Thread | [Next in Thread] |