summaryrefslogtreecommitdiff
path: root/programs/sub-suite/declare.s
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-08-09 17:52:46 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-08-09 17:52:46 -0400
commit2b03202a30e9da09bfc5c0d382b1f5d2287287a4 (patch)
tree6b918e0f2eee2b56e07a95d8b8397143d24f9106 /programs/sub-suite/declare.s
parentf16af793a58a9f398fc598a0c129e3bb90eb61f6 (diff)
Added the bitwise OR, left shift, and right shift
expressions to the emulator's assembler.
Diffstat (limited to 'programs/sub-suite/declare.s')
-rw-r--r--programs/sub-suite/declare.s456
1 files changed, 337 insertions, 119 deletions
diff --git a/programs/sub-suite/declare.s b/programs/sub-suite/declare.s
index 2991e66..8054956 100644
--- a/programs/sub-suite/declare.s
+++ b/programs/sub-suite/declare.s
@@ -51,22 +51,23 @@ PTOK_PLUS = 4 ; +
PTOK_MINUS = 5 ; -
PTOK_GT = 6 ; >
PTOK_LT = 7 ; <
-PTOK_LBRAK = 8 ; (
-PTOK_RBRAK = 9 ; )
-PTOK_COMMA = 10 ; ,
-PTOK_X = 11 ; x
-PTOK_Y = 12 ; y
-PTOK_S = 13 ; s
-PTOK_P = 14 ; p
-PTOK_DQUOT = 15 ; "
-PTOK_SQUOT = 16 ; '
-PTOK_HASH = 17 ; #
-PTOK_SCOLN = 18 ; ;
-PTOK_DOLR = 19 ; $
-PTOK_PRCNT = 20 ; %
-PTOK_NUM = 21 ; 0-9
-PTOK_ALPH = 22 ; a-z A-Z
-PTOK_OTHR = 23 ; Everything else.
+PTOK_PIPE = 8 ; |
+PTOK_LBRAK = 9 ; (
+PTOK_RBRAK = 10 ; )
+PTOK_COMMA = 11 ; ,
+PTOK_X = 12 ; x
+PTOK_Y = 13 ; y
+PTOK_S = 14 ; s
+PTOK_P = 15 ; p
+PTOK_DQUOT = 16 ; "
+PTOK_SQUOT = 17 ; '
+PTOK_HASH = 18 ; #
+PTOK_SCOLN = 19 ; ;
+PTOK_DOLR = 20 ; $
+PTOK_PRCNT = 21 ; %
+PTOK_NUM = 22 ; 0-9
+PTOK_ALPH = 23 ; a-z A-Z
+PTOK_OTHR = 24 ; Everything else.
; Expressions.
EXPR_PLUS = 0 ; Plus.
@@ -75,6 +76,22 @@ EXPR_LOW = 2 ; Lower half of address.
EXPR_HIGH = 3 ; Upper half of address.
EXPR_NONE = 4 ; No expression.
+; Addressing modes.
+IMM = 1 << 0 ; Immediate Data.
+ZM = 1 << 1 ; Zero Matrix.
+ZMX = 1 << 2 ; Zero Matrix, indexed with X.
+ZMY = 1 << 3 ; Zero Matrix, indexed with Y.
+IND = 1 << 4 ; Indirect.
+INDX = 1 << 5 ; Indexed Indirect.
+INDY = 1 << 6 ; Indirect Indexed.
+ABS = 1 << 7 ; Absolute.
+REL = 1 << 8 ; Relative.
+BREG = 1 << 9 ; B Register.
+IMPL = 1 << 10 ; Implied.
+INDX2 = 1 << 11 ; Special case of INDX that uses the indirect table.
+ZM2 = 1 << 12 ; Special case of Zero Matrix used by JMP, and JSR.
+
+
; RAM declarations.
; Linewrap table.
@@ -272,109 +289,309 @@ bits:
; Instruction mnemonics, and opcodes.
-; Legend.
-; mne = Mnemonic.
-; imm = Immediate data.
-; zm = Zero Matrix.
-; zmx = Zero Matrix, indexed with X.
-; zmy = Zero Matrix, indexed with Y.
-; ind = Indirect.
-; idx = Indexed Indirect.
-; idy = Indirect Indexed.
-; abs = Absolute.
-; rel = Relative.
-; imp = Implied.
+; Format.
+;
+; String : Mnemonic.
+; 2 bytes: Addressing mode bits.
+; 1 byte : Base value, used to generate the actual opcode.
mne:
-; mne imm, zm, zmx, zmy, ind, idx, idy, abs, rel, imp
- .byte "ADC", $01, $06, $FF, $FF, $FF, $FF, $FF, $04, $FF, $FF
- .byte "AAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $02
- .byte "ABA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $22
- .byte "ADC", $01, $06, $FF, $FF, $FF, $FF, $FF, $04, $FF, $FF
- .byte "AND", $21, $26, $FF, $FF, $FF, $FF, $FF, $24, $FF, $FF
- .byte "ARB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $F2
- .byte "ASR", $F1, $F6, $FF, $FF, $FF, $FF, $FF, $F4, $FF, $FF
- .byte "BCC", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $80, $FF
- .byte "BCS", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $70, $FF
- .byte "BEQ", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $90, $FF
- .byte "BNE", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $A0, $FF
- .byte "BNG", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $60, $FF
- .byte "BPO", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $50, $FF
- .byte "BRA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $D0, $FF
- .byte "BRK", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $68
- .byte "BVC", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $FF
- .byte "BVS", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $B0, $FF
- .byte "CAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $B2
- .byte "CLC", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $08
- .byte "CLI", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $28
- .byte "CLV", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $48
- .byte "CMP", $B1, $B6, $FF, $FF, $25, $7D, $7C, $B4, $FF, $FF
- .byte "CPB", $2A, $2D, $FF, $FF, $55, $AD, $AC, $2C, $FF, $FF
- .byte "CPS", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $00
- .byte "CPX", $3A, $4D, $FF, $FF, $FF, $FF, $FF, $3C, $FF, $FF
- .byte "CPY", $4A, $3D, $FF, $FF, $FF, $FF, $FF, $4C, $FF, $FF
- .byte "DAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $A2
- .byte "DEB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C2
- .byte "DEC", $FF, $0D, $FF, $FF, $FF, $FF, $FF, $0C, $FF, $0A
- .byte "DEX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $09
- .byte "DEY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $29
- .byte "DIV", $A1, $A6, $FF, $FF, $FF, $FF, $FF, $A4, $FF, $FF
- .byte "INB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $D2
- .byte "INC", $FF, $1D, $FF, $FF, $FF, $FF, $FF, $1C, $FF, $1A
- .byte "INX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $19
- .byte "INY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $39
- .byte "JMP", $FF, $30, $FF, $FF, $B5, $FF, $FF, $10, $FF, $FF
- .byte "JSR", $FF, $40, $FF, $FF, $A5, $FF, $FF, $20, $FF, $FF
- .byte "LDA", $C1, $C6, $B8, $78, $05, $5D, $5C, $C4, $FF, $FF
- .byte "LDB", $D1, $D6, $D8, $98, $35, $8D, $8C, $D4, $FF, $FF
- .byte "LDX", $B9, $BD, $FF, $FF, $85, $FF, $FF, $BC, $FF, $FF
- .byte "LDY", $E1, $E6, $FF, $FF, $65, $FF, $FF, $E4, $FF, $FF
- .byte "LLB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $52
- .byte "LRB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $62
- .byte "LSL", $51, $56, $FF, $FF, $FF, $FF, $FF, $54, $FF, $FF
- .byte "LSR", $61, $66, $FF, $FF, $FF, $FF, $FF, $64, $FF, $FF
- .byte "MAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $92
- .byte "MUL", $91, $96, $FF, $FF, $FF, $FF, $FF, $94, $FF, $FF
- .byte "NOP", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $EA
- .byte "OAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $32
- .byte "ORA", $31, $36, $FF, $FF, $FF, $FF, $FF, $34, $FF, $FF
- .byte "PHA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $79
- .byte "PHB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $99
- .byte "PHP", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $59
- .byte "PHX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $E9
- .byte "PHY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C9
- .byte "PLA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $89
- .byte "PLB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $A9
- .byte "PLP", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $69
- .byte "PLX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $F9
- .byte "PLY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $D9
- .byte "RLB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $72
- .byte "ROL", $71, $76, $FF, $FF, $FF, $FF, $FF, $74, $FF, $FF
- .byte "ROR", $81, $86, $FF, $FF, $FF, $FF, $FF, $84, $FF, $FF
- .byte "RRB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $82
- .byte "RTI", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $F0
- .byte "RTS", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $E0
- .byte "SAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $12
- .byte "SBC", $11, $16, $FF, $FF, $FF, $FF, $FF, $14, $FF, $FF
- .byte "SEC", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $18
- .byte "SEI", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $38
- .byte "STA", $FF, $CD, $C8, $88, $15, $6D, $6C, $CC, $FF, $FF
- .byte "STB", $FF, $DD, $E8, $A8, $45, $9D, $9C, $DC, $FF, $FF
- .byte "STX", $FF, $FD, $FF, $FF, $95, $FF, $FF, $FC, $FF, $FF
- .byte "STY", $FF, $ED, $FF, $FF, $75, $FF, $FF, $EC, $FF, $FF
- .byte "TAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $5A
- .byte "TAX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $9A
- .byte "TAY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $7A
- .byte "TBA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $6A
- .byte "TSX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $DA
- .byte "TXA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $AA
- .byte "TXS", $FA, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
- .byte "TXY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $CA
- .byte "TYA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $8A
- .byte "TYX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $BA
- .byte "WAI", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $58
- .byte "XAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $42
- .byte "XOR", $41, $46, $FF, $FF, $FF, $FF, $FF, $44, $FF, $FF
+ .byte "ADC"
+ .word IMM|ZM|ABS|BREG
+ .byte $01
+
+ .byte "AND"
+ .word IMM|ZM|ABS|BREG
+ .byte $41
+
+ .byte "ASR"
+ .word IMM|ZM|ABS|BREG
+ .byte $62
+
+ .byte "BCC"
+ .word REL
+ .byte $A0
+
+ .byte "BCS"
+ .word REL
+ .byte $90
+
+ .byte "BEQ"
+ .word REL
+ .byte $B0
+
+ .byte "BNE"
+ .word REL
+ .byte $C0
+
+ .byte "BNG"
+ .word REL
+ .byte $80
+
+ .byte "BPO"
+ .word REL
+ .byte $70
+
+ .byte "BRA"
+ .word REL
+ .byte $F0
+
+ .byte "BRK"
+ .word IMPL
+ .byte $69
+
+ .byte "BVC"
+ .word REL
+ .byte $E0
+
+ .byte "BVS"
+ .word REL
+ .byte $D0
+
+ .byte "CLC"
+ .word IMPL
+ .byte $09
+
+ .byte "CLI"
+ .word IMPL
+ .byte $29
+
+ .byte "CLV"
+ .word IMPL
+ .byte $49
+
+ .byte "CMP"
+ .word IMM|ZM|IND|INDY|ABS|BREG|INDX2
+ .byte $82
+
+ .byte "CPB"
+ .word IMM|ZM|IND|INDY|ABS|INDX2
+ .byte $04
+
+ .byte "CPS"
+ .word IMPL
+ .byte $00
+
+ .byte "CPX"
+ .word IMM|ZM|IND|ABS
+ .byte $24
+
+ .byte "CPY"
+ .word IMM|ZM|IND|ABS
+ .byte $44
+
+ .byte "DEB"
+ .word IMPL
+ .byte $99
+
+ .byte "DEC"
+ .word IMPL|ZM|ABS
+ .byte $84
+
+ .byte "DEX"
+ .word IMPL
+ .byte $B9
+
+ .byte "DEY"
+ .word IMPL
+ .byte $79
+
+ .byte "DIV"
+ .word IMM|ZM|ABS|BREG
+ .byte $42
+
+ .byte "INB"
+ .word IMPL
+ .byte $A9
+
+ .byte "INC"
+ .word IMPL|ZM|ABS
+ .byte $A4
+
+ .byte "INX"
+ .word IMPL
+ .byte $C9
+
+ .byte "INY"
+ .word IMPL
+ .byte $89
+
+ .byte "JMP"
+ .word ABS|IND|ZM2
+ .byte $00
+
+ .byte "JSR"
+ .word ABS|IND|ZM2
+ .byte $20
+
+ .byte "LDA"
+ .word IMM|ZM|ZMX|ZMY|IND|INDX|INDY|ABS
+ .byte $C2
+
+ .byte "LDB"
+ .word IMM|ZM|ZMX|ZMY|IND|INDX|INDY|ABS
+ .byte $E2
+
+ .byte "LDX"
+ .word IMM|ZM|IND|ABS
+ .byte $64
+
+ .byte "LDY"
+ .word IMM|ZM|IND|ABS
+ .byte $A2
+
+ .byte "LSL"
+ .word IMM|ZM|ABS|BREG
+ .byte $A1
+
+ .byte "LSR"
+ .word IMM|ZM|ABS|BREG
+ .byte $C1
+
+ .byte "MUL"
+ .word IMM|ZM|ABS|BREG
+ .byte $22
+
+ .byte "NOP"
+ .word IMPL
+ .byte $EA
+
+ .byte "ORA"
+ .word IMM|ZM|ABS|BREG
+ .byte $61
+
+ .byte "PHA"
+ .word IMPL
+ .byte $8E
+
+ .byte "PHB"
+ .word IMPL
+ .byte $AE
+
+ .byte "PHP"
+ .word IMPL
+ .byte $6E
+
+ .byte "PHX"
+ .word IMPL
+ .byte $EE
+
+ .byte "PHY"
+ .word IMPL
+ .byte $CE
+
+ .byte "PLA"
+ .word IMPL
+ .byte $9E
+
+ .byte "PLB"
+ .word IMPL
+ .byte $BE
+
+ .byte "PLP"
+ .word IMPL
+ .byte $7E
+
+ .byte "PLX"
+ .word IMPL
+ .byte $FE
+
+ .byte "PLY"
+ .word IMPL
+ .byte $DE
+
+ .byte "ROL"
+ .word IMM|ZM|ABS|BREG
+ .byte $E1
+
+ .byte "ROR"
+ .word IMM|ZM|ABS|BREG
+ .byte $02
+
+ .byte "RTI"
+ .word IMPL
+ .byte $60
+
+ .byte "RTS"
+ .word IMPL
+ .byte $50
+
+ .byte "SBC"
+ .word IMM|ZM|ABS|BREG
+ .byte $21
+
+ .byte "SEC"
+ .word IMPL
+ .byte $19
+
+ .byte "SEI"
+ .word IMPL
+ .byte $39
+
+ .byte "STA"
+ .word ZM|ZMX|ZMY|IND|INDX|INDY|ABS
+ .byte $28
+
+ .byte "STB"
+ .word ZM|ZMX|ZMY|IND|INDX|INDY|ABS
+ .byte $48
+
+ .byte "STX"
+ .word ZM|IND|ABS
+ .byte $68
+
+ .byte "STY"
+ .word ZM|IND|ABS
+ .byte $08
+
+ .byte "TAB"
+ .word IMPL
+ .byte $0A
+
+ .byte "TAX"
+ .word IMPL
+ .byte $4A
+
+ .byte "TAY"
+ .word IMPL
+ .byte $2A
+
+ .byte "TBA"
+ .word IMPL
+ .byte $1A
+
+ .byte "TSX"
+ .word IMPL
+ .byte $8A
+
+ .byte "TXA"
+ .word IMPL
+ .byte $5A
+
+ .byte "TXS"
+ .word IMPL|IMM
+ .byte $9A
+
+ .byte "TXY"
+ .word IMPL
+ .byte $7A
+
+ .byte "TYA"
+ .word IMPL
+ .byte $3A
+
+ .byte "TYX"
+ .word IMPL
+ .byte $6A
+
+ .byte "WAI"
+ .word IMPL
+ .byte $59
+
+ .byte "XOR"
+ .word IMM|ZM|ABS|BREG
+ .byte $81
+
; Command subroutine table.
cmd_srt:
@@ -397,6 +614,7 @@ swtab:
.word ptok_min ; PTOK_MINUS
.word ptok_gt ; PTOK_GT
.word ptok_lt ; PTOK_LT
+ .word ptok_pipe ; PTOK_PIPE
.word ptok_lbrk ; PTOK_LBRAK
.word ptok_rbrk ; PTOK_RBRAK
.word ptok_com ; PTOK_COMMA
@@ -421,10 +639,10 @@ hex_char:
; Compare, and return table for pre-tokens.
ptok_tab:
- .byte ".@:=+-><(),xysp\"\'#;$%"
+ .byte ".@:=+-><|(),xysp\"\'#;$%"
; Compare, and return table for isdelm.
dtab:
.byte "\n,\"\' \\"
; Compare, and return table for isdelm2.
dtab2:
- .byte "),.+<>-=;\n"
+ .byte "),.+<|>-=;\n"