Hi, Can anyone please point me to some resources for learning about interfacing C and assembler modules in gcc-avr?
I've been looking at the asmdemo code from avr-libc, but it only goes part way with overall explanation. I'm especially needing to learn how to write assembler (.S) modules containing C-callable functions, and how to handle issues like: - how to access the arguments passed in by the calling C function - how to safely procure registers for temporary storage, without breaking (or being broken by) any neighbouring C code - how to allocate and access global variables, and make these available to C code - how to access C global variables - how to return values to the C caller - how to call C functions - how to pass arguments and retrieve the return value I'd much rather steer away from using inline assembler inside C functions. The syntax is not to my taste, to say the least. Back in my Z80 and 8086 C/assembler hacking days, it was way simple. All C funcs/vars were just prefixed with an underscore, arguments were pushed onto the return stack along with the return address, and returned values were passed back through clearly-defined registers. The code in /doc/examples/asmdemo in the avr-libc tree is only limited value, because all the assembler code seems to be just ISRs, with no calling between C and assembler. Can anyone point me to some simple examples? Or should I just trawl through the lower layers of avr-libc source and pick it up by osmosis? Thanks in advance for any help. Cheers David PS - my current project is a minimalistic dual-stack VM. The core VM engine, written in straight C, weighs in at a hefty 150 bytes, which is an embarrassing disgrace, and needs some serious liposuction, down to about 50-80 bytes, if the VM is to be viable on the smaller ATtiny MCUs. _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list