Prev: 05709 Up: Map Next: 05732
05714: 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 05714 LD BC,1 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 05717 PUSH HL Save the pointer.
05718 CALL TEST_ROOM Make sure that there is sufficient memory available for the task being undertaken.
05721 POP HL Restore the pointer.
05722 CALL POINTERS Alter all the pointers before making the 'room'.
05725 LD HL,(23653) Make HL hold the new STKEND.
05728 EX DE,HL Switch 'old' and 'new'.
05729 LDDR Now make the 'room' and return.
05731 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: 05709 Up: Map Next: 05732