Prev: 168F Up: Map Next: 16B0
169E: THE 'RESERVE' SUBROUTINE
Used by the routine at BC_SPACES.
On entry here the last value on the machine stack is WORKSP and the value above it is the number of spaces that are to be 'reserved'.
This subroutine always makes 'room' between the existing work space and the calculator stack.
Input
BC Number of spaces to reserve
Output
DE Address of the first byte of the new space
HL Address of the last byte of the new space
RESERVE 169E LD HL,($5C63) Fetch the current value of STKBOT and decrement it to get the last location of the work space.
16A1 DEC HL
16A2 CALL MAKE_ROOM Now make 'BC spaces'.
16A5 INC HL Point to the first new space and then the second.
16A6 INC HL
16A7 POP BC Fetch the old value of WORKSP and restore it.
16A8 LD ($5C61),BC
16AC POP BC Restore BC - number of spaces.
16AD EX DE,HL Switch the pointers.
16AE INC HL Make HL point to the first of the displaced bytes.
16AF RET Now return.
Note: it can also be considered that the subroutine returns with the DE register pair pointing to a 'first extra byte' and the HL register pair pointing to a 'last extra byte', these extra bytes having been added after the original '(HL)+1' location.
Prev: 168F Up: Map Next: 16B0