From: Matthias T. <mt...@we...> - 2013-03-12 18:18:15
|
Hi Mark, > First of all - thanks to you and all your cohorts for Amforth! I have been > using Forth for 30 years (F83 ... ) for a variety of projects and Amforth > (since 4.2) with the 328P as my current platform. Wow. A Forth Guru. Welcome! > A quick question: for timing purposes, I have dropped into assembly > (driving the SPI system as a slave to a Raspberry Pi since the Pi isn't > easy to slave! BTW, the Pi is my ISP too, fun!) I'm trashing the X register > r26 & r27 to index into SRAM - so when I exit my code via 'JMP_ DO_NEXT' > I'm back at the interpeter prompt (surprise!). Where... and how.. is the > safest way to save the IP ... and what else might I be trashing? (I am > using temp0 thru 7 (except for temp5)) There a few occasions, where I need two index registers. placing them on the (CPU-) stack within one assembler word works fine: push xl push xh ... do some work with XH:XL, but no jmp DO_NEXT pop xh pop xl > > My thinking is to use r31:r30 in place of r27:r26 . The ZH:ZL is fine. Keep in mind that no CPU register is guaranteed to survive the inner interpreter (aka a jmp DO_NEXT). (the currently unused CPU registers are reserved for future use, not that I have an actual use for them, but...). Matthias PS: The atmega SPI system can do the slave work too. Did you check the datasheets? I've not used it myself however. |