Prev: 05775 Up: Map Next: 05808
05790: 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 05790 LD HL,(23651) Fetch the current value of STKBOT and decrement it to get the last location of the work space.
05793 DEC HL
05794 CALL MAKE_ROOM Now make 'BC spaces'.
05797 INC HL Point to the first new space and then the second.
05798 INC HL
05799 POP BC Fetch the old value of WORKSP and restore it.
05800 LD (23649),BC
05804 POP BC Restore BC - number of spaces.
05805 EX DE,HL Switch the pointers.
05806 INC HL Make HL point to the first of the displaced bytes.
05807 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: 05775 Up: Map Next: 05808