XFER

Developer(s): David Ornstein
Date: 1982
Type: Program
Platform(s): ZX81, TS 1000

Machine code is often printed as hex. With XFER you type the bytes into REM lines that start with ( and end the list with a REM $ line; the program finds each REM, turns each pair of hex digits into a byte, collects the bytes in Z$ and calls them with USR. The download includes the article’s example, a few bytes that add 16 and 32 and return the result: after RUN, PRINT VALUE shows 48.

Z$ must be the first variable the program creates, because the start address of the code is worked out from VARS. In line 330 the word REM inside the quotes is the REM keyword. The article also shows how to POKE the bytes into a REM in line 1 instead. In testing, RUN in a 1K ZX81 stopped with report 4; with 2K or more the example works.

Published in Syntax June 1982 (Loading Hexadecimal Listings).

Related Articles

This program converts the hex and stores it into a space explicitly for it.

Image Gallery

Source Code

  10 REM ( 3E 10 06 20 80 06 00 4F C9
  20 REM $
 100 REM XFER
 110 LET Z$=""
 120 LET A=16513-5
 140 LET SA=PEEK 16400+PEEK 16401*256+3
 200 REM MAIN LOOP
 210 GOSUB 300
 220 IF X$="(" THEN GOSUB 400
 230 IF X$="$" THEN GOTO 1000
 240 GOTO 200
 300 REM FIND A REM
 310 LET A=A+5
 320 LET X=PEEK A
 325 LET X$=CHR$ X
 330 IF X$=" REM " THEN GOTO 370
 340 LET A=A+1
 350 IF PEEK A=118 THEN GOTO 300
 360 GOTO 340
 370 LET A=A+1
 380 LET X=PEEK A
 385 LET X$=CHR$ X
 390 RETURN
 400 REM PROCESS A LINE
 410 GOSUB 500
 420 IF EOL=1 THEN RETURN
 430 LET H=(X-28)*16+PEEK (A+1)-28
 440 LET A=A+1
 450 LET Z$=Z$+CHR$ H
 460 GOTO 400
 500 REM FIND A NON-SPACE CHAR
 505 LET EOL=0
 510 LET A=A+1
 520 LET X=PEEK A
 530 IF X=0 THEN GOTO 510
 540 IF X=118 THEN LET EOL=1
 550 LET X$=CHR$ X
 560 RETURN
1000 REM DONE WITH XFER
1010 LET VALUE=USR SA

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.