ZX81/TS1000 Tips

See all articles from SINCUS v6 n3

3. Here is a little function, which may be placed at the beginning or within a machine code program, to stop the program until the tape player starts inputing data.

XXXX DBFE HOLD: IN A, (FE)

CB7F         BIT 7, A
28FA JR Z, HOLD

Where: XXXX represents the address.

4. This is a routine to set RAMTOP and then install your machine code above it.

As an example lets say that you have 80 bytes of machine code in 1 REM and you want to install it at address 30000 [7530 hex].

BASIC part: UPLOAD Machine Code:

1 REM [ your machine code ]     40D8 213075    UPLOAD:   LD HL, 7530; New RAMTOP
2 REM [ UPLOAD machine code ] 220440 LD(RAMTOP), HL
10 ) -- your 2B DEC HL
--- ) -- BASIC 363E LD (HL), 3E
--- ) -- program 2B DEC HL
--- ) -- listing 3600 LD (HL), 00
8999 STOP 2B DEC HL
9000 SAVE "name" 3606 LD (HL), 06
9010 RAND USR 16600 2B DEC HL
9020 RUN 3676 LD (HL), 76
220240 LD (ERR.SP), HL
F9 LD SP, HL
218240 LD HL, SOURCE
113075 LD DE, DESTINATION
015000 LD BC, No. of BYTES
EDB0 LDIR
C9 RET

34 Bytes

To determine the address of “UPLOAD”, PEEK 16511 + 256 * PEEK 16512 + 4 using a direct command. Then add this number to 16514. The result will be the required address.

In my example there are no extra bytes in 1 REM. Therefore the PEEK would give 86. 16514 + 86 = 16600

ED NOTE: This is the second in a series of hints and tips Don has gleaned from several years of digging away at his 1000. His ability to take one through a difficult subject is appreciated.