ZX 81 assembler using TASM in MS Windows

Machine code
Post Reply
Site Admin
Posts: 15
Joined: Tue Apr 02, 2019 5:29 pm

ZX 81 assembler using TASM in MS Windows

Post by Admin » Sun May 05, 2019 5:44 pm

TASM is a great way to develop machine code programs for the ZX81. The main advantage is that all coding is done outside the Zeddy environment, meaning no delays loading an assembler, saving the code and repeating every time something goes wrong or the RAM pack wobbles.

A link to TASM and some extras follows. Just download and extract to anywhere convenient on a Windows based PC.
(227.91 KiB) Downloaded 4 times

The only additional program you may need is an editor. Its possible to use MS Notepad or Wordpad but these are a bit basic. I use Notepad++, https://notepad-plus-plus.org/download/v7.6.6.html, which offers a lot more features including line numbers.

OK, one of the extra files is named, _blank.asm. Make a copy of this and rename the copy to something suitable. To help illustrate TASM, I am going to write a screen invert routine which will invert all the characters every time its called. So my working file is invert.asm.

The file includes links to support files (includes). These are necessary for producing ZX81 compatible .p file. The includes are :

#include "./includes/zx81defs.asm"

;EQUs for ROM routines
#include "./includes/zx81rom.asm"

;ZX81 char codes/how to survive without ASCII
#include "./includes/charcodes.asm"

;system variables
#include "./includes/zx81sys.asm"

;the standard REM statement that will contain our 'hex' code
#include "./includes/line1.asm"

; code starts here and gets added to the end of the REM

; >>>>You new code is inserted here <<<<
; ===========================================================
; code ends
; ===========================================================
;end the REM line and put in the RAND USR line to call our 'hex code'

; line 10 which calls the code @ 16514
#include "./includes/line2.asm"

;display file defintion
#include "./includes/screen.asm"

;close out the basic program
#include "./includes/endbasic.asm"

Save your code, but don't close the editor, before compiling.

To make compilation easy, there is a batch file named _Compile.bat. When run it expects a file name to be entered, for this example, the file was named invert.asm. So just enter invert.

If everything goes well, an invert.p file will be created which can then be run on an emulator such as Eightyone or ZEsarUX, or copied to a memory card for use with ZXPand or vDrive and run on a real Zeddy.

If there are errors in the code, the line number and error description will be displayed. From there it is just a matter of checking the source code in the editor, correcting all errors found and running the _Compile batch file again.

Here's the code for my invert routine:

; Will invert characters on screen

ld hl, (16396) ; HL=Start of display file
inc hl ; Jump past first N/L characters
ld bc, 726 ; Number of characters in 22x32 screen inc. N/L

loop ld a, (hl)
cp 118 ; check for N/L
jr z, nxtchar ; Jump to next character, we dont mess with 118s
xor 128 ; Invert character
ld (hl), a ; Copy back to screen

nxtchar inc hl ; Next character
dec bc
ld a, b
or c
jr nz, loop

;back to BASIC


Some additional files are created, these are used by TASM during compilation:

<filename>.lst which is a text file expanded with the additional files referenced in <filename>.asm
<filename>.sym which is a list of values assigned to symbolic addresses and constants.

Post Reply