Prev: 06415 Up: Map Next: 06510
All of the character/token codes in a BASIC line are printed by repeatedly calling this subroutine.
OUT_SP_2 06437 LD A,E The A register will hold 32 for a space or 255 for no-space.
06438 AND A Test the value and return if there is not to be a space.
06439 RET M
06440 JR OUT_CHAR Jump forward to print a space.
This entry point is used by the routine at OUT_NUM_1 to print a line number that may (E=32) or may not (E=255) require leading spaces.
OUT_SP_NO 06442 XOR A Clear the A register.
The HL register pair holds the line number and the BC register the value for 'repeated subtraction' (-1000, -100 or -10).
OUT_SP_1 06443 ADD HL,BC The 'trial subtraction'.
06444 INC A Count each 'trial'.
06445 JR C,OUT_SP_1 Jump back until exhausted.
06447 SBC HL,BC Restore last 'subtraction' and discount it.
06449 DEC A
06450 JR Z,OUT_SP_2 If no 'subtractions' were possible jump back to see if a space is to be printed.
06452 JP OUT_CODE Otherwise print the digit.
This entry point is used by the routine at OUT_LINE to print a character or token.
OUT_CHAR 06455 CALL NUMERIC Return carry reset if handling a digit code.
06458 JR NC,OUT_CH_3 Jump forward to print the digit.
06460 CP 33 Also print the control characters and 'space'.
06462 JR C,OUT_CH_3
06464 RES 2,(IY+1) Signal 'print in K-mode' (reset bit 2 of FLAGS).
06468 CP 203 Jump forward if dealing with the token 'THEN'.
06470 JR Z,OUT_CH_3
06472 CP ":" Jump forward unless dealing with ':'.
06474 JR NZ,OUT_CH_1
06476 BIT 5,(IY+55) Jump forward to print the ':' if in 'INPUT mode' (bit 5 of FLAGX set).
06480 JR NZ,OUT_CH_2
06482 BIT 2,(IY+48) Jump forward if the ':' is 'not in quotes' (bit 2 of FLAGS2 reset), i.e. an inter-statement marker.
06486 JR Z,OUT_CH_3
06488 JR OUT_CH_2 The ':' is inside quotes and can now be printed.
OUT_CH_1 06490 CP "\"" Accept for printing all characters except '"'.
06492 JR NZ,OUT_CH_2
06494 PUSH AF Save the character code whilst changing the 'quote mode'.
06495 LD A,(23658) Fetch FLAGS2 and flip bit 2.
06498 XOR 4
06500 LD (23658),A Enter the amended value into FLAGS2 and restore the character code.
06503 POP AF
OUT_CH_2 06504 SET 2,(IY+1) Signal 'the next character is to be printed in L-mode' (set bit 2 of FLAGS).
OUT_CH_3 06508 RST 16 The present character is printed before returning.
06509 RET
Note: it is the consequence of the tests on the present character that determines whether the next character is to be printed in 'K' or 'L' mode.
Also note how the program does not cater for ':' in REM statements.
Prev: 06415 Up: Map Next: 06510