Prev: 1652 Up: Map Next: 168F
1664: 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 1664 PUSH AF These registers are saved.
1665 PUSH HL Copy the address of the 'position'.
1666 LD HL,$5C4B This is VARS, the first of the fourteen system pointers.
1669 LD A,$0E
A loop is now entered to consider each pointer in turn. Only those pointers that point beyond the 'position' are changed.
PTR_NEXT 166B LD E,(HL) Fetch the two bytes of the current pointer.
166C INC HL
166D LD D,(HL)
166E EX (SP),HL Exchange the system variable with the address of the 'position'.
166F AND A The carry flag will become set if the system variable's address is to be updated.
1670 SBC HL,DE
1672 ADD HL,DE
1673 EX (SP),HL Restore the 'position'.
1674 JR NC,PTR_DONE Jump forward if the pointer is to be left; otherwise change it.
1676 PUSH DE Save the old value.
1677 EX DE,HL Now add the value in BC to the old value.
1678 ADD HL,BC
1679 EX DE,HL
167A LD (HL),D Enter the new value into the system variable - high byte before low byte.
167B DEC HL
167C LD (HL),E
167D INC HL Point again to the high byte.
167E POP DE Fetch the old value.
PTR_DONE 167F INC HL Point to the next system variable and jump back until all fourteen have been considered.
1680 DEC A
1681 JR NZ,PTR_NEXT
Now find the size of the block to be moved.
1683 EX DE,HL Put the old value of STKEND in HL and restore the other registers.
1684 POP DE
1685 POP AF
1686 AND A Now find the difference between the old value of STKEND and the 'position'.
1687 SBC HL,DE
1689 LD B,H Transfer the result to BC and add 1 for the inclusive byte.
168A LD C,L
168B INC BC
168C ADD HL,DE Reform the old value of STKEND and pass it to DE before returning.
168D EX DE,HL
168E RET
Prev: 1652 Up: Map Next: 168F