Prev: 190F Up: Map Next: 196E
1925: THE 'PRINTING CHARACTERS IN A BASIC LINE' SUBROUTINE
All of the character/token codes in a BASIC line are printed by repeatedly calling this subroutine.
OUT_SP_2 1925 LD A,E The A register will hold +20 for a space or +FF for no-space.
1926 AND A Test the value and return if there is not to be a space.
1927 RET M
1928 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=+20) or may not (E=+FF) require leading spaces.
OUT_SP_NO 192A 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 192B ADD HL,BC The 'trial subtraction'.
192C INC A Count each 'trial'.
192D JR C,OUT_SP_1 Jump back until exhausted.
192F SBC HL,BC Restore last 'subtraction' and discount it.
1931 DEC A
1932 JR Z,OUT_SP_2 If no 'subtractions' were possible jump back to see if a space is to be printed.
1934 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 1937 CALL NUMERIC Return carry reset if handling a digit code.
193A JR NC,OUT_CH_3 Jump forward to print the digit.
193C CP $21 Also print the control characters and 'space'.
193E JR C,OUT_CH_3
1940 RES 2,(IY+$01) Signal 'print in K-mode' (reset bit 2 of FLAGS).
1944 CP $CB Jump forward if dealing with the token 'THEN'.
1946 JR Z,OUT_CH_3
1948 CP ":" Jump forward unless dealing with ':'.
194A JR NZ,OUT_CH_1
194C BIT 5,(IY+$37) Jump forward to print the ':' if in 'INPUT mode' (bit 5 of FLAGX set).
1950 JR NZ,OUT_CH_2
1952 BIT 2,(IY+$30) Jump forward if the ':' is 'not in quotes' (bit 2 of FLAGS2 reset), i.e. an inter-statement marker.
1956 JR Z,OUT_CH_3
1958 JR OUT_CH_2 The ':' is inside quotes and can now be printed.
OUT_CH_1 195A CP "\"" Accept for printing all characters except '"'.
195C JR NZ,OUT_CH_2
195E PUSH AF Save the character code whilst changing the 'quote mode'.
195F LD A,($5C6A) Fetch FLAGS2 and flip bit 2.
1962 XOR $04
1964 LD ($5C6A),A Enter the amended value into FLAGS2 and restore the character code.
1967 POP AF
OUT_CH_2 1968 SET 2,(IY+$01) Signal 'the next character is to be printed in L-mode' (set bit 2 of FLAGS).
OUT_CH_3 196C RST $10 The present character is printed before returning.
196D 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: 190F Up: Map Next: 196E