| Routines

1F05: THE 'TEST-ROOM' SUBROUTINE

Used by the routines at LD_CONTRL, ED_EDIT, ONE_SPACE, FREE_MEM and TEST_5_SP. The routine at GO_SUB continues here. A series of tests is performed to ensure that there is sufficient free memory available for the task being undertaken.
Input
BC | Size of the required space
Output
HL | STKEND+BC+80-SP
TEST_ROOM | 1F05 | LD HL,($5C65) | Increase the value taken from STKEND by the value carried into the routine by the BC register pair.
| 1F08 | ADD HL,BC
| 1F09 | JR C,REPORT_4 | Jump forward if the result is over +FFFF.
| 1F0B | EX DE,HL | Try it again allowing for a further eighty bytes.
| 1F0C | LD HL,$0050
| 1F0F | ADD HL,DE
| 1F10 | JR C,REPORT_4
| 1F12 | SBC HL,SP | Finally test the value against the address of the machine stack.
| 1F14 | RET C | Return if satisfactory.
This entry point is used by the routines at GET_HLxDE and DIM. Report 4 - Out of memory.
REPORT_4 | 1F15 | LD L,$03 | This is a 'run-time' error and the error marker is not to be used.
| 1F17 | JP ERROR_3