summaryrefslogtreecommitdiff
path: root/programs/subasm-2.s
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-03-17 15:07:20 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-03-17 15:36:07 -0400
commit071edf621a6722f94027f37720a5a5f73d9696c0 (patch)
tree87761e6dca9e7cf47bf0b6f2d52e8e31623ac01a /programs/subasm-2.s
parent917f864a6d1304d9f0c650c107a5fd6576690cb7 (diff)
Revamped the opcode table, made the emulator more
efficient, and ported SuBEditor to C. I revamped the opcode table to add another prefix bit for the addressing mode, finally giving access to all addresses, without wasting any bytes. I made the stack based operations more efficient, by sort of applying Duff's device to it. And I ported SuBEditor to C, to make it easier for me to figure out how to implement SuBAsm.
Diffstat (limited to 'programs/subasm-2.s')
-rw-r--r--programs/subasm-2.s151
1 files changed, 151 insertions, 0 deletions
diff --git a/programs/subasm-2.s b/programs/subasm-2.s
new file mode 100644
index 0000000..f77116b
--- /dev/null
+++ b/programs/subasm-2.s
@@ -0,0 +1,151 @@
+; SuBAsm
+; The Sux Bootstrapped Assembler.
+;
+; by mr b0nk 500 <b0nk@b0nk.xyz>
+
+
+.org $A000
+; String Constants.
+prg_name:
+ .byte "SuBAsm"
+ver_txt:
+ .byte ", version "
+ver_num:
+ .byte "0.1"
+
+; Directives.
+dir:
+ .byte "org"
+ .byte "byte"
+ .byte "word"
+ .byte "dword"
+ .byte "qword"
+tok:
+ .byte '.'
+ .byte '#'
+ .byte '$'
+ .byte '%'
+ .byte '('
+ .byte ')'
+ .byte ','
+
+mne:
+ .byte "AAB"
+ .byte "ABA"
+ .byte "ADC"
+ .byte "AND"
+ .byte "ARB"
+ .byte "ASR"
+ .byte "BCC"
+ .byte "BCS"
+ .byte "BEQ"
+ .byte "BNE"
+ .byte "BNG"
+ .byte "BPO"
+ .byte "BRK"
+ .byte "BVC"
+ .byte "BVS"
+ .byte "CAB"
+ .byte "CLC"
+ .byte "CLI"
+ .byte "CLV"
+ .byte "CMP"
+ .byte "CPB"
+ .byte "CPS"
+ .byte "CPX"
+ .byte "CPY"
+ .byte "DAB"
+ .byte "DEB"
+ .byte "DEC"
+ .byte "DEX"
+ .byte "DEY"
+ .byte "DIV"
+ .byte "ENT"
+ .byte "INB"
+ .byte "INC"
+ .byte "INX"
+ .byte "INY"
+ .byte "JMP"
+ .byte "JSL"
+ .byte "JSR"
+ .byte "LDA"
+ .byte "LDB"
+ .byte "LDX"
+ .byte "LDY"
+ .byte "LLB"
+ .byte "LRB"
+ .byte "LSL"
+ .byte "LSR"
+ .byte "MAB"
+ .byte "MUL"
+ .byte "NOP"
+ .byte "OAB"
+ .byte "ORA"
+ .byte "PHA"
+ .byte "PHB"
+ .byte "PHP"
+ .byte "PHX"
+ .byte "PHY"
+ .byte "PLA"
+ .byte "PLB"
+ .byte "PLP"
+ .byte "PLX"
+ .byte "PLY"
+ .byte "RLB"
+ .byte "ROL"
+ .byte "ROR"
+ .byte "RRB"
+ .byte "RTI"
+ .byte "RTL"
+ .byte "RTS"
+ .byte "SAB"
+ .byte "SBC"
+ .byte "SEC"
+ .byte "SEI"
+ .byte "STA"
+ .byte "STB"
+ .byte "STT"
+ .byte "STX"
+ .byte "STY"
+ .byte "TAB"
+ .byte "TAX"
+ .byte "TAY"
+ .byte "TBA"
+ .byte "TSX"
+ .byte "TXA"
+ .byte "TXS"
+ .byte "TXY"
+ .byte "TYA"
+ .byte "TYX"
+ .byte "WAI"
+ .byte "XAB"
+ .byte "XOR"
+
+; Start of program code.
+.org $8600
+subasm:
+ ldb #0
+ lda.w #tok
+ sta.q ptr2
+ tba
+ jsl chk_tok
+
+ jsl chk_mne
+chk_tok:
+ phy #2
+ txy
+ lda (ptr6), y
+ cmp (ptr2), y
+ ply #2
+ cpx #7
+ beq tok_false
+tok_true:
+ inb
+tok_false:
+ stb f
+tok_end:
+ ldb #0
+ rtl
+
+chk_mne:
+ ply #2