Here’s a quick post on how I got some Z80 assembly code onto my Z80 SC114 SBC from Linux. This is using the fantastic Small Computer Monitor software that comes pre-installed.
First, install the necessary packages. Be sure to use z80asm and z80dasm from the repositories rather than the one that comes with z88dk if you have that installed.
From Linux: –
sudo apt install z80asm z80dasm srecord
Or from MacOS: –
brew install z80asm z80dasm srecord
Here’s the test assembly that I used from the excellent Small Computer Monitor Tutorial PDF on this page. I saved this as “keyboard.asm”, it just waits for a keypress before delaying then outputting it back.
LD C,1 ;API call 1 = Input character
RST $30 ;API call inputs a character
PUSH AF ;Remember the key character
LD C,+10 ;API call 10 = Delay by DE milliseconds
LD DE,+1000 ;Delay in milliseconds
RST $30 ;API call delays for 1 seconds
POP AF ;Restore the key character
LD C,2 ;API call 2 = Output character
RST $30 ;API call outputs character
To create a binary file from this assembly code, run the following command: –
z80asm -i keyboard.asm -o keyboard.bin
You can check the contents of this binary file by disassembling it back: –
z80dasm -a -t -g 0x8000 keyboard.bin
Small Computer Monitor requires the code to be in Intel hex format, so to convert it, use the following command: –
srec_cat keyboard.bin -binary -offset 0x8000 -output keyboard.hex -intel -address-length=2
You should then be able to send this text to your SBC by copying the contents if this file onto the clipboard then pasting via GtkTerm or whatever you’re using. The message “Ready” should be shown in SCM.
To run the code, enter the following in your terminal session, and it should work: –