Programming the DrACo/Z80

Here are instructions on how to program the 8-bit, program counter, breadboard variant of the DrACo/Z80 computer.

  • Set the clock to automatic / oscillator mode (so the clock is running) 
  • Set Program/Run to Program (~BUSRQ low)
    • The address should now be controlled by the counter chip.
  • Enter in the program, one byte at a time:
    • Wait for the BUSAK LED to light
    • Click Up (blue) or Down (green) until you reach the address you want to program. (The buttons can be flaky, but you’ll get there eventually.)
    • Set the logic switches to the data byte to be written
    • Press Write (white button).
    • Click Up or Down to move to the next address
    • Continue until the program has been entered
  • When the program is entered, run it:
    • Press and hold Reset
    • While holding Reset, switch to Run mode
    • Wait for the BUSAK LED to go out
    • Continue to hold down Reset for the length of 15-20 clock cycles
    • If you want to step through the program, switch the clock to Manual. To have it run automatically, leave the clock in Automatic
    • Release Reset
    • If stepping through the program, press STEP repeatedly

 

Remember to start your programs with a NOP (0x00) in address 0x00. (This is because address 00 is sometimes overwritten when running a program. Extra credit for anyone who can help me track down that particular bug, for sure!)

A note on the Z80’s memory refresh sequence:

After execution of each instruction, the Z80 will perform a refresh sequence, where it will call on the next memory location in the refresh sequence. It uses an overflowing 7-bit counter for this (yes, really), so it counts up from 0x00 to 0x7F before resuming at 0x00.

Suppose you entered the following program:

Address  Data   Instruction
———————————
00             00      NOP
01              C3      JMP
02             00      00
03             00      00

You would see the following sequence of addresses accessed:
00 (NOP)
00 (refresh)
01 (jmp)
02 (00) (part of jmp)
03 (00) (part of jmp)
01 (refresh)
00 (NOP)
02 (refresh)
01 (jmp)
02 (00) (part of jmp)
03 (00) (part of jmp)
03 (refresh)
00 (NOP)

All seems more or less correct at this point, but then you might notice numbers appearing outside your code location:

04 (refresh)
01 (jmp)
02 (00)
03 (00)
05 (refresh)
00 (NOP)
06 (refresh)

It looks like your program is running away — but it’s just the refresh cycle doing its thing. Watch it run for a few cycles until you see the 00 C3 00 00 interspersed with the 00 01 02 03 04 05 etc.

With the static RAM chips we use, we don’t actually need all this refresh silliness — but it’s baked in to the Z80 and can’t be disabled. Modern PC hardware does include refresh functionality, but it’s essentially abstracted away at this point, from a programmer’s perspective.

This entry was posted in Assembly, Coding, Digital, DrACo/Z80, Drexel, EET325, Electronics, HOW-TO. Bookmark the permalink.

Leave a Reply