;
;SAVE ALL - this program saves the stack pointer, RETurn address and normal
;/alternate registers. It runs with interrupts disabled and enables them
;upon its return. Put the XOR loops gleaned from the game where you're told
;to in this listing and everything will be protected from corruption by them.
;The R register isn't saved, but who needs it anyway ?
;

nolist

           org &a000              ;Can be anywhere
           limit &ffff


.save      di
           push af                ;Save normal register set
           push bc
           push de
           push hl
           push ix
           push iy
           exx                    ;Swap to alternate set..
           push af                ;... and save them
           push bc
           push de
           push hl
           push ix
           push iy
           exx                    ;Back to the normal set
           ld (stack),sp          ;Save SP so all the registers can be POPed



;
;          *** PUT YER XOR LOOPS HERE !! ***
;



           ld sp,(stack)          ;Restore SP...
           exx                    ;...and the registers. First the alternate
           pop iy                 ;set...
           pop ix
           pop hl
           pop de
           pop bc
           pop af
           exx                    ;...and then the normal set.
           pop iy
           pop ix
           pop hl
           pop de
           pop bc
           pop af

           ei                     ;All registers etc. are restored so RETurn
           ret                    ;from whence ye were CALLed

.stack     defs 2                 ;Storage space for SP

list

;          *** This is the end of the program !! ***

