Prev: 05714 Up: Map Next: 05775
05732: THE 'POINTERS' SUBROUTINE
Used by the routines at ONE_SPACE and RECLAIM_1.
Whenever an area has to be 'made' or 'reclaimed' the system variables that address locations beyond the 'position' of the change have to be amended as required. On entry the BC register pair holds the number of bytes involved and the HL register pair addresses the location before the 'position'.
Input
BC Size of the area being created (positive) or reclaimed (negative)
HL Base address of the area being created or reclaimed
POINTERS 05732 PUSH AF These registers are saved.
05733 PUSH HL Copy the address of the 'position'.
05734 LD HL,23627 This is VARS, the first of the fourteen system pointers.
05737 LD A,14
A loop is now entered to consider each pointer in turn. Only those pointers that point beyond the 'position' are changed.
PTR_NEXT 05739 LD E,(HL) Fetch the two bytes of the current pointer.
05740 INC HL
05741 LD D,(HL)
05742 EX (SP),HL Exchange the system variable with the address of the 'position'.
05743 AND A The carry flag will become set if the system variable's address is to be updated.
05744 SBC HL,DE
05746 ADD HL,DE
05747 EX (SP),HL Restore the 'position'.
05748 JR NC,PTR_DONE Jump forward if the pointer is to be left; otherwise change it.
05750 PUSH DE Save the old value.
05751 EX DE,HL Now add the value in BC to the old value.
05752 ADD HL,BC
05753 EX DE,HL
05754 LD (HL),D Enter the new value into the system variable - high byte before low byte.
05755 DEC HL
05756 LD (HL),E
05757 INC HL Point again to the high byte.
05758 POP DE Fetch the old value.
PTR_DONE 05759 INC HL Point to the next system variable and jump back until all fourteen have been considered.
05760 DEC A
05761 JR NZ,PTR_NEXT
Now find the size of the block to be moved.
05763 EX DE,HL Put the old value of STKEND in HL and restore the other registers.
05764 POP DE
05765 POP AF
05766 AND A Now find the difference between the old value of STKEND and the 'position'.
05767 SBC HL,DE
05769 LD B,H Transfer the result to BC and add 1 for the inclusive byte.
05770 LD C,L
05771 INC BC
05772 ADD HL,DE Reform the old value of STKEND and pass it to DE before returning.
05773 EX DE,HL
05774 RET
Prev: 05714 Up: Map Next: 05775