Sunday, March 30, 2014

JMON - 8080 Version

I wanted to learn some Intel 8080 assembler programming, so I selected as a project to write a port of my JMON machine language monitor program that I wrote for the 6502 and Briel Apple 1 Replica.

After a couple of evenings of hacking I have a version running with six of the commands implemented. It is not so much a port, as an implementation from scratch of a subset of the commands and features of the 6502 version.

Some sample output is shown below (user input is in bold).

JMON Monitor 0.1 by Jeff Tranter
? ?
Valid commands:
C start end dest           Copy memory
D address                  Dump memory
F start end data...        Fill memory
G address                  Go
I                          Show info
K start end                Checksum
L                          Clear screen
R                          Examine registers
S start end data...        Search memory
T start end                Test memory
V start end dest           Verify memory
: address data...          Write to memory
= address +/- address      Hex math calculation
?                          Help

? I
JMON Monitor 0.1 by Jeff Tranter
CPU type: 8080

? R
A=00 BC=0000 DE=0000 HL=0000 F=00000110 SP=7000 PC=0000

? D 0000
0000: 32 9E 06 78 32 A0 06 79 32 A1 06 7A 32 A2 06 7B 2..x2..y2..z2..{
0010: 32 A3 06 7C 32 A4 06 7D 32 A5 06 F5 C1 79 32 9F 2..|2..}2....y2.
0020: 06 21 00 70 7C 32 A6 06 7D 32 A7 06 31 00 70 CD .!.p|2..}2..1.p.
0030: E5 02 21 A7 03 CD EC 02 3E 3F CD 92 02 CD FC 02 ..!......?......
0040: CD A1 02 CD 04 03 FE 43 C2 51 00 CD 85 02 C3 38 .......C.Q.....8
0050: 00 FE 44 C2 5C 00 CD EC 00 C3 38 00 FE 46 C2 67 ..D.\.....8..F.g
0060: 00 CD 85 02 C3 38 00 FE 47 C2 72 00 CD 4A 01 C3 .....8..G.r..J..
0070: 38 00 FE 49 C2 7D 00 CD 90 01 C3 38 00 FE 4B C2 8..I.}.....8..K.
0080: 88 00 CD 85 02 C3 38 00 FE 4C C2 93 00 CD 89 01 ......8..L......
0090: C3 38 00 FE 52 C2 9E 00 CD BC 01 C3 38 00 FE 53 .8..R.......8..S
00A0: C2 A9 00 CD 85 02 C3 38 00 FE 54 C2 B4 00 CD 85 .......8..T.....
00B0: 02 C3 38 00 FE 56 C2 BF 00 CD 85 02 C3 38 00 FE ..8..V.......8..
00C0: 3A C2 CA 00 CD 85 02 C3 38 00 FE 3D C2 D5 00 CD :.......8..=....
00D0: 85 02 C3 38 00 FE 3F C2 E0 00 CD 7B 02 C3 38 00 ...8..?....{..8.
00E0: CD AB 02 21 CA 03 CD EC 02 C3 38 00 CD 92 02 CD ...!......8.....
00F0: FC 02 CD 9C 03 D2 FC 00 CD AB 02 C9 CD AB 02 0E ................
0100: 18 E5 CD 43 03 3E 3A CD 92 02 06 10 CD FC 02 7E ...C..:........~
0110: CD 11 03 23 05 C2 0C 01 CD FC 02 E1 06 10 7E CD ...#..........~.
0120: D0 02 23 05 C2 1E 01 CD AB 02 0D C2 01 01 E5 21 ..#............!
0130: 51 06 CD EC 02 E1 CD A1 02 FE 1B C2 42 01 CD AB Q...........B...
0140: 02 C9 FE 20 CA FC 00 C3 36 01 CD 92 02 CD FC 02 ... ....6.......
0150: CD 9C 03 D2 5A 01 CD AB 02 C9 22 A8 06 CD AB 02 ....Z.....".....
0160: 2A 00 00 E5 3A A8 06 6F 3A A9 06 67 E5 3A A4 06 *...:..o:..g.:..
0170: 67 3A A5 06 6F 3A A2 06 57 3A A3 06 5F 3A A0 06 g:..o:..W:.._..
Press Space to continue, ESC to stop 

? G 0000

It builds using the AS Macro Assembler. The binary can be put on an SD card and directly loaded into the Briel Altair 8800 memory and run.

I found debugging quite straightforward by using the front panel switches of the Briel Altair 8800. In particular, the ability to step, see disassembly on the console, and set a breakpoint address, were very useful. The JMON monitor makes some things a little easier than the front panel, like dumping the contents of memory.

While my goal was to learn 8080 assembly language programming, the monitor is somewhat useful in it's current form. You can find the source code here. It is licensed under the Apache 2.0 license so you are free to use it for any purpose. As time allows, I may implement more commands and features.

Being mostly familiar with the 6502, and its successors like the 6809 and 68000, it was interesting to see how the Intel 8080 compared. It has more registers and instructions than the 6502, making some things easier, but the learning curve is perhaps higher. It also has a few unusual instructions and quirks (for example, how do you clear the carry bit?).

2 comments:

Corneleous Worthington said...

Hi Jeff,
Thank you for making your JMON source available! I downloaded your source code, and implemented the : write-to-memory feature. I'm a newbie with coding in Assembly (that's what this is, correct?), so I don't know how good or bad my code is.. It does work... :-)

I've tested it after cross assembly on an Altair emulator. After it was working, I put the BIN file on an SD card, and it runs on my Altair 8800micro clone that I built from scratch.. Cool stuff!!

Here is my code, in case you'd want to use it in your official JMON (although I'm such a green coder, it won't hurt my feelings if you don't!)

; Write command.
; (-aka- "MemoryCommand")
; Allows entry directly into memory..
;
MemoryCommand:
;initial time through, start address is entered..
call PrintChar ; Echo the command back
call PrintSpace
call GetAddress ; Prompt for start address
jc finish
;xchg
call PrintSpace
call GetByte
jc finish
mov b,a
;write:
mov m,b ; Store in target address
call PrintCR
;now repeat subsequent times through unless ESC is pressed..
repeatwrite:
inx h ; increment address pointer
mov a,h
mov b,l
lxi h,strSpacer
call PrintString
mov h,a
mov l,b
call PrintSpace
call PrintAddress
call PrintSpace
call GetByte
jc finish
mov b,a
;write:
mov m,b ; Store in target address
call PrintCR
jmp repeatwrite

Corneleous Worthington said...

Oops! Forgot this part- down in the string section:
strSpacer:
db "? :",0