Below you will find pages that utilize the taxonomy term “Tutorial”
Msx Assembly 101: 08 Using z88dk
Recently I found z88dk, “the C and assembler development kit that comes ready out-of-the-box to create programs for over 100 z80-family (8080, 8085, gbz80, z80, z180, ez80_z80, KC160, Rabbit 2000, 3000, 4000, 5000) machines”. Given that z88dk can create binaries for AgonLight computer which I have now (albeit only in Z80 mode with 64k of memory accessible), I naturally got interested.
First attempt
Let us take the following assembler file zfirst.asm
:
CHPUT equ 00A2h
ld a,'A'
call CHPUT
Compiling it with zcc +msx -subtype=rom2 -o zfirst.rom zfirst.asm
yields an
error about undefined symbol _main
. Of course, z88dk links the executable
with crt0
which expects (as it would happen with C program) that the entry
point _main
is defined.
Msx Assembly 101: 06 Printd
This is the next installment in my
MSX Assembly 101
series. We are going to develop here printd
routine, which will print the
decimal value of the byte is the accumulator.
Comparing to printh
(hexadecimal representation) there is an additional
complication: hexadecimal representation always contains two digits (for
example, the byte 0x01
is printed as 01
, with leading zero); the number
of digits in the decimal representation depends on the value of the number:
Msx Assembly 101: 05 Printh
This is another post in the series about Z80 assembly (on MSX).
Previous posts:
In this post I will describe a creation of routine printh
which will
print hexadecimal representation of a byte in the accumulator register a
.
Setup
I am going to make the code which can be compiled both as a cartridge and
as a CP/M com file. The setup for this is described in the post
Using YAZE and
expaned in post Stack.
Moreover, I am going to write the code in two parts: printh
implementation
itself and some code to “test” it by running.
Msx Assembly 101: 04 Stack
Stack in cartridges
According to MSX Technical Handbook, a cartridge software should initialize
stack pointer before using the stack. The common practice is to put 0xF380
into sp
register (see
this)
and remember that stack grows downwards.
It means that any cartridge program, which uses the stack, should near its
beginning do something like ld sp, 0f380h
.
Stack in CP/M programs
When a CP/M program starts execution, sp
points to the stack of 16 bytes.
Since any subroutine call puts a return address on the stack, you can do no
more than 7 nested calls if you do not use stack and do not call BDOS
routines (2 bytes are already consumed by the CP/M return address, used when
your program does final ret
). Due to this, it is a good practice to use own
stack space in CP/M program. Moreover, CP/M expects that the program preserves
stack pointer. It all means that the following should be done at the start of a
program:
Msx Assembly 101: 03 Using YAZE
Recently I found myself spending days (it will be one month with two weeks break in the middle) in a place, where I have an internet connection but not a computer. I do have an iPad with a keyboard, though, and it has SSH- and VNC-clients. Unfortunately, there are too many hops to home and too many hoops to jump (including port-forwarding over reverse SSH tunnel) to use VNC comfortably. This means that I cannot use MSX emulators. However, I wanted to continue my experiments with Z80 programming – over SSH.
MSX Assembly 101: 02 Printz
This post will continue my MSX Assembly 101 series, started here.
We are going to develop the routine printz
for displaying to the screen
0-terminated strings.
Control flow
Z80 CPU supports two types of jumps: jr
and jp
. There are also two commands
for working with subroutines: call
to call a subroutine and ret
to return
from it. Each of these command can take a condition, making control flow
transition conditional on some flag. For example, ret z
will return from the
subroutine, but only if the flag Z is set.
MSX Assembly 101: 01 Introduction
This is hopefully the first post in a series devoted to assembly programming for MSX computers.
A little bit of history
When I was a schoolboy (and now I am over 50) we had Yamaha computers in school. They were implementing MSX standard and had Zilog Z80 CPU. Recently I have got interested in retrocomputing, and, while I do not have older hardware, there are multiple emulators, and I can even run MSX emulator on my Android TV (which has Bluetooth keyboard connected to it). Playing with MSX I feel like I am young and back at school again.