Close

Writing and loading programs for the Messy80

A project log for Messy 80

A Z80 single board computer, just because.

oliverdOliver.D 03/19/2018 at 10:290 Comments

This will be a description of the steps taken to write and run programs.

1. Program is written in assembler starting at address 0x8400

; ---------------------------------------------------------------------;
; Print out Hello World!!!                                             ;
; ---------------------------------------------------------------------;
#include "labels.ass"

#target     rom                 ; declare target file format

#code       $8400,$4000        ; declare main code segment

hello_world:

    ld       HL, str_hello_world
    call     print_string
    call     new_line
    ret

str_hello_world     defm    "Hello World!"+$80

#end

 2. Before assembling the program a script gets the symbols used in the monitor so that routines such as 'print_string' can be used. The symbols are saved into labels.ass

zasm conveniently can produces a log file with all the symbols defined.

3. The program is assembled with zasm.

4. Yet another script is called that reads the bin file and outputs commands for the monitor that will write the program to the RAM. The commands saved into a text file.

This is what it looks like:

wa 8400,21
wa 8401,0A
wa 8402,84
wa 8403,CD
wa 8404,E8
wa 8405,03
wa 8406,CD
wa 8407,BF
wa 8408,03
wa 8409,C9
wa 840A,48
wa 840B,65
wa 840C,6C
wa 840D,6C
wa 840E,6F
wa 840F,20
wa 8410,57
wa 8411,6F
wa 8412,72
wa 8413,6C
wa 8414,64
wa 8415,A1

5. 'Picocom' and 'ascii-xfr' are used to send the commands to the monitor.

6. Finally address 0x8400 is called.

This is the result in the serial monitor:

#
*** file: -s -l 10 /home/oliver/workspace/z80/messy80/programs/hello_world/hello_world.txt
$ ascii-xfr -s -l 10 /home/oliver/workspace/z80/messy80/programs/hello_world/hello_world.txt
ASCII upload of "/home/oliver/workspace/z80/messy80/programs/hello_world/hello_world.txt"
Line delay: 10 ms, character delay 0 ms

wa 8400,21
#wa 8401,0A
#wa 8402,84
#wa 8403,CD
#wa 8404,F8
#wa 8405,03
#wa 8406,CD
#wa 8407,CF
#wa 8408,03
#wa 8409,C9
#wa 840A,48
#wa 840B,65
#wa 840C,6C
#wa 840D,6C
#wa 840E,6F
#wa 840F,20
#wa 8410,57
#wa 8411,6F
#wa 8412,72
#wa 8413,6C
#wa 8414,64
#wa 8415,A1
#
*** exit status: 0

#ca 8400
Hello World!
Successfuly returned
#

Discussions