| Routines

07408: THE 'IF' COMMAND ROUTINE

The address of this routine is found in the parameter table. On entry the value of the expression between the IF and the THEN is the 'last value' on the calculator stack. If this is logically true then the next statement is considered; otherwise the line is considered to have been finished.
IF_CMD | 07408 | POP BC | Drop the return address - STMT_RET.
| 07409 | CALL SYNTAX_Z | Jump forward if checking syntax.
| 07412 | JR Z,IF_1
Now use the calculator to 'delete' the last value on the calculator stack but leave the DE register pair addressing the first byte of the value.
| 07414 | RST 40 | Use the calculator.
| 07415 | DEFB 2 | delete
| 07416 | DEFB 56 | end_calc
| 07417 | EX DE,HL | Make HL point to the first byte and call TEST_ZERO.
| 07418 | CALL TEST_ZERO
| 07421 | JP C,LINE_END | If the value was 'FALSE' jump to the next line.
IF_1 | 07424 | JP STMT_L_1 | But if 'TRUE' jump to the next statement (after the THEN).