ZX81/TS1000 Tips

See all articles from SINCUS v6 n5

7. A five byte machine code routine to save printer paper while copying screen:

This routine is fully relocatable. For our example we will put it in 1 REM and it will copy 8 lines.

ENTRY POINT:
                       -> 4082      1608      WD D, 08; 8 dec.
(16514)  C36B08      JP 086B

5 bytes

Using BASIC it can be put in as follows:

1  REM  12345
10 POKE 16514, 22
20 POKE 16515, 8 [The number of lines to be copied (1 to 24 dec.)]
30 POKE 16516, 195
40 POKE 16517, 107
50 POKE 16518, 8
Direct command -  RUN   <ENTER>      Then DELETE lines 50 to 10

To use this routine from BASIC set up a line for the USR call and use GOTO whenever you want to copy other than the normal 22 lines.

Example: 2000 RAND USR 16514
Direct command GOTO 2000

NOTE: A direct command – RAND USR 16514 <ENTER> will clear the screen and print so many empty lines.

To use this routine from Machine code just use a jump, relative jump or a call. The AF, BC, DE and HL register pairs are all changed, therefore push all the ones you want to keep onto the STACK before running the routine and pop them back afterwards.

8. To find the Line Address from the Line Number:

Push AF,BC, DE, and HL onto the STACK if they contain information you don’t want to lose. Then Load HL with the Line number integers. Next call 09D8, Line-Addr subroutine. The Line address will be returned in HL.

Example: Find the Line address of the Line Number 350.

xxxx F5          PUSH AF
C5 PUSH BC
D5 PUSH DE
E5 PUSH HL
215E01 LD HL, 015E; 350 DEC.
CDD809 CALL 09D8, LINE-ADDR.

At this point HL will contain the line address in interger form.

Ed. Note: Thanks Don for this continuing series on short machine code routines for the 1000. You can dust off the old 1000 and kick some of these ideas around. You might even want to try them on the 2068.