I have been looking at the ROM disassembly and noticed the routines reference system variables using the IY register. IY is set to 23610 and system vars are read using an offset to IY. This is useful for loading a system variable into registers other than A, as LD r,(IY+N) can be used on all the registers, at a cost of 3 extra T-cycles to LD a,(NN). It also means you can relocate the system variables and change the IY register to point to the new location.
Why did the designers use this method?
The IY register and the Spectrum ROM
Re: The IY register and the Spectrum ROM
why not? ;-) it is common practice to use IX/IY to access some array of variables. array of system variables looks like a perfect fit.
p.s.: they stole my register! i can't use it even if i'm not calling ROM, because ISR at #38 expects it to point at sysvars. HAET.
p.s.: they stole my register! i can't use it even if i'm not calling ROM, because ISR at #38 expects it to point at sysvars. HAET.
Re: The IY register and the Spectrum ROM
It's a very space efficient way of accessing the system variables. The Speccy ROM code is optimised to fit as much in to as small a space as possible, even at the expense of performance. And probably have them more flexibility during the design about where the system variables would ultimately be placed.