Several people made their own Z80 computer. I found this one which run Microsoft BASIC, so I made it run on the Monsputer.
Just some minor modifications specific to the hardware were needed to set the baud rate, and initialize the interrupts.
By looking in the assembler code, there is an interesting and clever trick: instead of putting relative jumps, which take 2 bytes, there are ‘skip’ instructions which only take 1 byte!
(In those times, RAM was costly and every bytes counted)
How they do this? The ‘skip’ instruction is really a 8-bit or 16-bit load immediate instruction. The 8-bit allows to skip 1 byte, the 16-bit one allows to skip 2 bytes. Let’s see this in action.
The following code is an example with a relative jump.
sbr_val2: push hl ld hl,#value2 jr sbr_ex sbr_val1: push hl sbr_ex: <instructions> pop hl ret
With the skip trick, it becomes:
sbr_val2: push hl ld hl,#value2 .db 0x3e ;ld a,#0xE5 used as a skip instruction: ;push hl is read as a data byte and ;is not executed sbr_val1: push hl sbr_ex: <instructions> pop hl ret