PokeMon wrote:Yes - if the compiler creates an application it must be loaded somehow on the ZX81. Usually it can only read "BASIC programs" which may contain assembly code as well. As the stack pointer is initialized before a program is loaded (how else would you start LOAD "") I wouldn't care about changing the stack pointer manually.
The compiler is targeted to Z80 (ZX Spectrum CPU).PokeMon wrote:If you are more familiar with assembly then you may use other tools as well. Don't know Boriel's language used.
ZX Basic compiled programs restore IX, SP, and HL' upon return. But AF' might be changed.PokeMon wrote: HL' (has to be restored before returning to BASIC)
IY (may be used in FAST mode with display turned off but should be restored when returning)
IX (may be used in FAST mode with display turned off but should be restored when returning)
AF' (may be used in FAST mode with display turned off but should be restored when returning)
I (may be used in SLOW mode but disturbs the picture until restored)
R (unlikely to use for general applications)
The compiler generates an "EXIT TO BASIC" (for ZX Spectrum) sequence at the end.
The compiler uses all of these tricks when generating code. Actually, the original SP is saved in memory (in a static location) and restored upon return.PokeMon wrote:If you need a temporary additional register using the stack with PUSH and followed by EX SP,(HL) is quite useful as well. This instruction swaps HL and top of stack and a second instruction changes back.
I and R are not used by the compiler.
The idea in mind is to have a generic Z80 compiler for the Z80 family (ala z88dk in C). But I moved into another city 2yrs ago and have really little time. Having said that, the project is alive.
What I lack is hardware info for those machines. I need to design an scheme to easily allow 3rd developers to do what nitrofurano is doing by hand: generating code for 3rd architectures.