From 69822f186cb4fc28f5533f741ad41920f1970f7c Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Mon, 2 Sep 2019 20:38:44 -0400 Subject: [PATCH] added mangomon source code --- mangomon/.gitignore | 3 + mangomon/Makefile | 11 +++ mangomon/mango1.dasm | 165 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 mangomon/.gitignore create mode 100644 mangomon/Makefile create mode 100644 mangomon/mango1.dasm diff --git a/mangomon/.gitignore b/mangomon/.gitignore new file mode 100644 index 0000000..c41f07b --- /dev/null +++ b/mangomon/.gitignore @@ -0,0 +1,3 @@ +*.bin +*.hex +*.lst diff --git a/mangomon/Makefile b/mangomon/Makefile new file mode 100644 index 0000000..534a6e7 --- /dev/null +++ b/mangomon/Makefile @@ -0,0 +1,11 @@ + +all: mango1.hex + +mango1.hex: mango1.bin + +%.bin: %.dasm + dasm $< -f3 -o$@ -L$*.lst + +%.hex: %.bin + hexdump -e '"" 8/1 "%02x\n" "\n"' $< > $@ + diff --git a/mangomon/mango1.dasm b/mangomon/mango1.dasm new file mode 100644 index 0000000..d965537 --- /dev/null +++ b/mangomon/mango1.dasm @@ -0,0 +1,165 @@ +a + processor 6502 + +Temp equ $2a +Addr equ $2c + + seg CODE + org $FF00 ; starting address + +h_Reset +Start + sei + cld + ldx #$ff + txs +CmdLoop + jsr DoCommand + jmp CmdLoop ; endless loop +DoCommand + jsr PutCR + lda #"#" ; prompt + jsr PutChar + jsr GetChar + cmp #"R" + beq DumpBytes + cmp #"W" + beq WriteBytes + cmp #"G" + beq GotoAddr + cmp #13 + beq DumpNext +Invalid + jsr PutCR + lda #"?" + jsr PutChar + jmp Start +DumpBytes + jsr GetHexWord +DumpNext + jsr PutHexAddr + lda #":" + jsr PutChar +DumpLoop + lda #" " + jsr PutChar + ldy #0 + lda (Addr),y + jsr PutHexByte + jsr IncAddr + lda Addr + and #$07 + bne DumpLoop + rts +WriteBytes + jsr GetHexWord + lda #":" + jsr PutChar + jsr GetHexByte + ldy #0 + sta (Addr),y + rts +GotoAddr + jsr GetHexWord + jmp (Addr) + +GetHexWord + lda #0 + sta Addr + sta Addr+1 + jsr GetHexDigit + bcs Bailout + beq GetHexWord ; eat leading zeroes +NextHexDigit + asl + asl + asl + asl + ldy #4 +ShiftAddr + asl + rol Addr + rol Addr+1 + dey + bne ShiftAddr + jsr GetHexDigit + bcs Bailout + jmp NextHexDigit +GetHexByte + jsr GetHexDigit + bcs Bailout + asl + asl + asl + asl + sta Temp + jsr GetHexDigit + bcs Bailout + ora Temp +Success + clc + rts +GetHexDigit + jsr GetChar + sec + sbc #"0" + cmp #10 + bcc Return + sbc #("A"-"0") ; carry already set + cmp #6 + bcs Bailout + clc + adc #10 + rts +Bailout + sec +Return + rts +PutCR + lda #13 + jmp PutChar +GetChar + lda $D010 + bpl GetChar + sta $D011 + and #$7f +PutChar + bit $D012 + bmi PutChar + sta $D012 + rts +PutHexAddr + lda Addr+1 + jsr PutHexByte + lda Addr +PutHexByte + pha + lsr + lsr + lsr + lsr + jsr PutHexDigit + pla +PutHexDigit + and #$0f + clc + adc #"0" + cmp #":" + bcc PutChar + adc #"A"-":"-1 + bcc PutChar +IncAddr + inc Addr + bne Return + inc Addr+1 + rts +h_BRK +; jsr PutChar +h_NMI + rti + + org $FFFA +Vectors + .word h_NMI + .word h_Reset + .word h_BRK