Prev: 164D Up: Map Next: 1664
1652: THE 'MAKE-ROOM' SUBROUTINE
Used by the routine at EDITOR.
This is a very important subroutine. It is called on many occasions to 'open up' an area. In all cases the HL register pair points to the location after the place where 'room' is required and the BC register pair holds the length of the 'room' needed.
Input
HL Address at which to create the new space
Output
DE Address of the last byte of the new space
HL Address of the byte before the start of the new space
When a single space only is required then the subroutine is entered here.
ONE_SPACE 1652 LD BC,$0001 Just the single extra location is required.
This entry point is used by the routines at LD_CONTRL, ME_ENTER, EDITOR, MAIN_ADD, RESERVE, FOR, DEF_FN, S_DECIMAL, LET and DIM with BC holding the size of the space to create.
MAKE_ROOM 1655 PUSH HL Save the pointer.
1656 CALL TEST_ROOM Make sure that there is sufficient memory available for the task being undertaken.
1659 POP HL Restore the pointer.
165A CALL POINTERS Alter all the pointers before making the 'room'.
165D LD HL,($5C65) Make HL hold the new STKEND.
1660 EX DE,HL Switch 'old' and 'new'.
1661 LDDR Now make the 'room' and return.
1663 RET
Note: this subroutine returns with the HL register pair pointing to the location before the new 'room' and the DE register pair pointing to the last of the new locations. The new 'room' therefore has the description '(HL)+1' to '(DE)' inclusive.
However as the 'new locations' still retain their 'old values' it is also possible to consider the new 'room' as having been made after the original location '(HL)' and it thereby has the description '(HL)+2' to '(DE)+1'.
In fact the programmer appears to have a preference for the 'second description' and this can be confusing.
Prev: 164D Up: Map Next: 1664