IX, IY and shadow registers
Re: IX, IY and shadow registers
Ha! I never knew any of that Thanks Fred!
Re: IX, IY and shadow registers
Well - the following registers can be used in all user programs without any care:
A, BC, DE, HL, BC', DE', HL' (AF,BC,DE,HL are stored during interrupts / picture generation and the double set is not used at all liek BC', DE', HL'.
The register IY could be used as well in FAST mode.
Can be used in SLOW mode as well with possible picture distortions but will come back when program is finished. The IY register is automatically restored when program returns from user program (RAND USR statement) but is (maybe accidently) used in the ROM in the video routine. This could be avoided when using the full address $4028 and $403B instead of IY+$28 and IY+$3B:
There is also a trick which can be used and copy the values of margin ($4028) and CDFLAG ($403B) at the locations/buffer where IY is pointing to in your program. So you won't have any distortion of picture display and can use IY in your program in SLOW mode as well.
The IX register can not be used in SLOW mode at all as it contains the return address after completing the picture with the interrupt routine at $0038.
Very useful and as an additional register is the instruction EX (SP),HL which is as quite useful as EX DE,HL but of course not as fast. EX DE,HL is very useful doing calculations with subtractions using SBC HL,DE while easily swapping subtrahend and minuend.
During FAST mode all registers can be used without any issue, even SP. Fast mode can be entered in user program with OUT ($FD),A and switched back with OUT ($FE),A but will result in a lost picture for that period or even a flickering due to a new synchronisation.
A, BC, DE, HL, BC', DE', HL' (AF,BC,DE,HL are stored during interrupts / picture generation and the double set is not used at all liek BC', DE', HL'.
The register IY could be used as well in FAST mode.
Can be used in SLOW mode as well with possible picture distortions but will come back when program is finished. The IY register is automatically restored when program returns from user program (RAND USR statement) but is (maybe accidently) used in the ROM in the video routine. This could be avoided when using the full address $4028 and $403B instead of IY+$28 and IY+$3B:
Code: Select all
;; DISPLAY-3
L0292: POP IX ; pop the return address to IX register.
; will be either L0281 or L028F - see above.
LD C,(IY+$28) ; load C with value of system constant MARGIN.
BIT 7,(IY+$3B) ; test CDFLAG for compute and display.
JR Z,L02A9 ; forward, with FAST mode, to DISPLAY-4
LD A,C ; move MARGIN to A - 31d or 55d.
NEG ; Negate
INC A ;
EX AF,AF' ; place negative count of blank lines in A'
OUT ($FE),A ; enable the NMI generator.
POP HL ; ****
POP DE ; ***
POP BC ; **
POP AF ; * Restore Main Registers
RET ; return - end of interrupt. Return is to
; user's program - BASIC or machine code.
; which will be interrupted by every NMI.
The IX register can not be used in SLOW mode at all as it contains the return address after completing the picture with the interrupt routine at $0038.
Very useful and as an additional register is the instruction EX (SP),HL which is as quite useful as EX DE,HL but of course not as fast. EX DE,HL is very useful doing calculations with subtractions using SBC HL,DE while easily swapping subtrahend and minuend.
During FAST mode all registers can be used without any issue, even SP. Fast mode can be entered in user program with OUT ($FD),A and switched back with OUT ($FE),A but will result in a lost picture for that period or even a flickering due to a new synchronisation.