I got a suitably dog-eared copy of 8080/Z80 Assembly Language Techniques for Improved Programming that covers the development of a system monitor in chapter 6.
The code is also available here, but the book breaks it down into stages so you can build up and debug the functionality step by step. This is invaluable since my 8080 byte-code interpreter is riddled with bugs!
There was some additional work needed before even getting through the first exercise in attaching the console. I needed a way to interface the virtual UART to the 8080 and the most elegant way of doing this was via the input/output ports. The first 8 were assigned to the expansion board, but the rest have now been assigned as follows:
Port# | Input | Output |
---|---|---|
0-7 | Expansion In | Expansion Out |
8 | Serial Rx | Serial Tx |
9 | Console (KBD) | Console (CRT) |
10 | KBD Scan Codes | Set Audio Mode |
11 | Cursor Character | Enable/Disable Rx |
12-55 | Zero Page Read | Zero Page Write |
56-63 | Zero Page Read Only | NOP |
The system's zero page is not addressable by the 8080, so 52 ports are mapped to this memory space via the ports. The first 44 bytes have read/write access and the last 8 are read only.
PORT $NAME ADDR DESCRIPTION
---- ----- ---- -----------
#SOUND (read/write)
12 $PCMPGH 0x8C # PCM page high water - stop page
13 $PCMPGL 0x8D # PCM page low water - current page
14 $WAVE0 0x8E
15 $ATTACK0 0x8F
16 $DECAY0 0x90
17 $SUSTAIN0 0x91
18 $RELEASE0 0x92
19 $NOTE1L 0x93 # note interval low (FREQL)
20 $NOTE1H 0x94 # note interval high (FREQH)
21 $WAVE1 0x95 # wave table entry (SQRWAV/SAWWAV: 0000WWWW)
22 $ATTACK1 0x96 # ADSR attack (positive 4-bit packed to 8-bits *8: 0AAAA000)
23 $DECAY1 0x97 # ADSR decay (negative 4-bit packed to 8-bits *8: 1DDDD000)
24 $SUSTAIN1 0x98 # ADSR sustain (negative 4-bit packed to 8-bits: 1111SSSS)
25 $RELEASE1 0x99 # ADSR release (negative 4-bit packed to 8-bits *8: 1RRRR000)
26 $NOTE2L 0x9A
27 $NOTE2H 0x9B
28 $WAVE2 0x9C
29 $ATTACK2 0x9D
30 $DECAY2 0x9E
31 $SUSTAIN2 0x9F
32 $RELEASE2 0xA0
33 $NOTE3L 0xA1
34 $NOTE3H 0xA2
35 $WAVE3 0xA3
36 $ATTACK3 0xA4
37 $DECAY3 0xA5
38 $SUSTAIN3 0xA6
39 $RELEASE3 0xA7
#CONSOLE (read/write)
40 $CONL 0xA8 # console left border
41 $CONR 0xA9 # console right border
42 $CONX 0xAA # console column
43 $CONY 0xAB # console row
44 $CONH 0xAC # console height from bottom
45 $CONB 0xAD # console backspace stop
46 $CONC 0xAE # console cursor char
47 $CONF 0xAF # console font
48 $VSTART 0xB0 # start of video display
48 $MODE 0xB1 # video mode to set
50 #SPARE 0xB2 (1)
51 $KTO 0xB3 # max kbd idle count
52 $KSRDIDX 0xB4
53 $KSWRIDX 0xB5
54 $KCRDIDX 0xB6
55 $KCWRIDX 0xB7
#PROTECTED STATE (read-only)
56 $KBSTAT 0xB8 # kbd status
57 #SPARE 0xB9 (1)
58 $BLOCK 0xBA # block count, 0 to 175/160/128
59 $FRAME 0xBB # frame count, -5,-4 to 0
60 $TIME0 0xBC # 15tps, max 90 - 6s
61 $TIME1 0xBD # 10tpm, max 120 - 12m
62 $TIME2 0xBE # 5tph, max 120 - 1d
63 $TIME3 0xBF # 1tpd, max 256 - 0.7y
The console provides a decoded keyboard input and a simple text terminal output to make interfacing easy for the system monitor.
The second exercise in the monitor development was the memory dump command. This is now working after debugging the associated 8080 instructions and arithmetic functions. The following animated GIF demonstrates dumping memory locations 0-300 in real time.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.