In this method needed variables is initialize during load the program.
And the question is: which variables on Zero Page is used by the Loaders on Gigatron?
I dont want crash during load by overlapping data.
A GT1 file should never write to locations 0x00-0x2f which are critical for all ROMs.
A GT1 file could write value 0x01 to location 0x80 (but only value 0x01). This is useful because a GT1 file can only target a single segment in page 0.
A GT1 file that writes in 0x30-0x41 interferes with the operation of the Serial Loader on ROM<=v6. No longer true on ROM=dev7. Not sure for ROM=vx0. Note that one can still load such a file from the ROM (with SYS_Exec_88) and from the SPI SDCard.
A GT1 file that writes into the stack space (above vSP-60) interferes with the operation of the rom loader (SYS_Exec_88). No longer true on ROM=dev7. Not sure for ROM=vx0. Note that one can still load such a file with the Loader or from the SPI SDCard.
Some zero page locations do not interfere with the loading process, but the values written there will not last long if one uses ROM features that depend on these locations: e.g. : 0x30-0x35 for vIRQ on ROM>=v5a, 0x81-0x8f for vCPU7 registers on ROM=dev7, 0x82-0xcf for various ROM=vx0 goodies (to be verified). But they're available if one does not use the corresponding ROM features.
Conclusion: For best compatibility, do not write anything below 0x42 or above 0xc0. Best is to avoid writing above 0x80.
Phibrizzo wrote: ↑31 Jul 2024, 12:53
You mean, writing above this address may be not safe for some ROMs. I understand.
I mean that you should first use the 62 bytes in [0x42-0x7f] because this is safe in all cases I know. Your program can also use [0x36-0x41] but you should not load values into these locations because that interferes with the loader. Make that [0x30-0x41] if you do not use vIRQ.
Then it depends on both the ROM you target and the ROMs people use to run your program. As long as you target ROMv6 or earlier, you will not use the vX0 or DEV7 extensions, and you can safely use [0x81-0xcf], even if running on vX0 or DEV7. To do so in a single segment you probably need to load 0x80 also, which is okay as long as you set it to value 0x1. The higher you go in page zero, the more you risk encroaching on the stack.
If you target vX0 or DEV7, you have new possibilities and new constraints. For instance, if you target DEV7, you can load values into [0x30-0x41] but your program should avoid using [0x81-0x8f] which contain extended vCPU registers. However you can also move the stack elsewhere in memory, making locations above 0xd0 available for use.
; declaration of varialbles
; p = 0x42 - start pointer declarated in compiler
WORD var0 #$5566 ; (*p) = #$5566, p+=2
BYTE var1 #$ff ; (*p) = #$FF, p++
Now compiler generated automatically initiation variables data and adds them to final gt1 file.
Now declaration is easer and final file can be few bytes shorter.