(Part 2 of an article on 8K routines. See Part 1, Sept.81–AZ)
‘Expand Display File’: The ZX81 (or 8K ROM) collapses its display file when times are hard–not enough memory. With a machine with less than 3.25K of RAM (genuinely or because you moved RAMTOP down) the display file is kept at only 25 NEWLINE characters. With a machine with more memory the display file is fully expanded (most of the time).
Because the display is or may be collapsed, the 8K monitor program must repeatedly test for the existence of the print position. If it is not there, the ROM must fill out the line so that the print position comes into being.
The RST 0010 routine (Sept.81) does this for every character that passes, but it does so by simply incrementing its existing values before calling the “expand if necessary” routine. However, the PRINT AT command allows you to choose any place in the display for the next print position.
This program shows how the PRINT AT operation can be performed. (In line 10, the first symbol is shift 1, the second shift D. Use the functions LN, NOT & TAN; don’t type them out.)
10 REM ▒5/LN /▒Y*NOT TAN
20 LET L=USR 16514
This places a * in the upper left position. The machine code in line 10 is:
LD BC,2118 ;PRINT AT 33,24 CALL 0918 ;inverted RST 0010 RET
Note that at this entry point the coordinates are reversed.
Get the PRINT AT positions oriented the proper way, then use the entry point of the “TEST PRINT AT values” routine at 08F5h. These lines will PRINT AT 12,12 (the first symbol is shift 1, the second shift A. Use the function key for LN, PRINT, NOT & TAN; don’t type them out).
10 REM ▒££LN PRINT ▒Y*NOT TAN
20 LET L=USR 16514
To type line 10, start with 10 PRINT. Backspace and add REM.
‘Print String’: The 8K ROM PRINT command routine at 0ACFh scans the PRINT statement and prints the required characters. All printing uses the RST 0010 instructions (Sept.81).
When you want to print a string, the DE register pair must hold the starting address of the text of the string. The BC register pair must hold the number of characters in the string. Then call 0B6Bh.
Try this program to see how 0B6B prints strings:
10 REM SYNTAX▒▒ )▒RNDLN ?"TAN
20 POKE 16528,107
30 LET L=USR 16520
40 GOTO 30
(The symbols are shift 1, shift E, and shift W. Use the function key for RND, LN and TAN.)
Here’s the machine code translation for line 10:
LD BC,+0007 ;7 string char. LD DE,+4082 ;address of the S CALL 0B6B ;print the 7 char. RET ;return to BASIC
The instruction 6B (decimal 107) cannot be entered from the keyboard, so you must POKE it into its address. Of course, you could enter all the instructions using POKE–it’s a matter of choice.
Try another example:
10 REM ▒ FOR ))▒LN ?"TAN
20 POKE 16521, 107
30 LET L=USR 16514
Again, for line 10 enter FOR, then backspace and enter REM. This program prints the command table as a string.
The identical BASIC program, which runs more slowly, is:
10 FOR A=273 TO 507
20 PRINT CHR$ PEEK A;
30 NEXT A
Note the last letter of each command word is in reverse video. The monitor uses this technique to show the end of the word.
(Dr. Logan added that he is interested in getting letters about any of his articles, and will try to answer all letters. His address: 24 Nurses Lane, Skellingthorpe, Lincoln, LN6 0TT, UK.)