summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--asmmon.c3
-rw-r--r--disasm.c8
-rw-r--r--opcode.h2
-rw-r--r--programs/sub-suite/declare.s24
-rw-r--r--programs/sub-suite/lexer.s102
-rw-r--r--programs/sub-suite/libc.s31
-rw-r--r--programs/sub-suite/subeditor.s4
-rw-r--r--programs/sub-suite/subsuite.s2
-rw-r--r--sux.c149
-rw-r--r--sux.h92
11 files changed, 296 insertions, 122 deletions
diff --git a/Makefile b/Makefile
index 4f234e4..f5f3606 100644
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,7 @@ CLK_CFLAGS=-Dgetclk=0
endif
+#OBJS = sux.o io.o $(DBG_OBJ) asmmon.o assemble.o lexer.o microcode.o
OBJS = sux.o io.o $(DBG_OBJ) asmmon.o assemble.o lexer.o
OBJS2 = subasm.o subeditor.o
OBJS3 = opcode-gen.o csv-parse.o
diff --git a/asmmon.c b/asmmon.c
index 876e6f0..6796ebb 100644
--- a/asmmon.c
+++ b/asmmon.c
@@ -536,7 +536,6 @@ int asmmon(const char *fn) {
}
fp2 = fopen(fn2, "r");
if (fp2 == NULL) {
- free(path);
fclose(fp);
cleanup();
return 2;
@@ -572,7 +571,7 @@ int asmmon(const char *fn) {
if (isspace(tmp[i])) {
for (; isspace(tmp[i]); i++);
}
- for (; !isspace(tmp[i]) && tmp[i] != '\0' && tmp[i] != '\n'; arg[j++] = tmp[i++]);
+ for (; !(isdelm(tmp[i], 0) & 0x11); arg[j++] = tmp[i++]);
arg[j] = '\0';
j = 0;
isdebug = (arg[j] == 'd' || !strcasecmp(arg, "debug"));
diff --git a/disasm.c b/disasm.c
index 3465f38..ff326d4 100644
--- a/disasm.c
+++ b/disasm.c
@@ -15,7 +15,11 @@ void print_regs(struct sux *cpu, uint8_t lines, uint8_t thread) {
wprintw(scr, ", x: $%016"PRIX64, cpu->x);
wprintw(scr, ", y: $%016"PRIX64, cpu->y);
wprintw(scr, ", sp: $%"PRIX64, cpu->sp);
- wprintw(scr, ", ps: $%02X", cpu->ps.u8[thread]);
+ wprintw(scr, ", ps: %c%c---%c%c%c", cpu->ps.u8[thread] & N ? 'N' : '-'
+ , cpu->ps.u8[thread] & V ? 'V' : '-'
+ , cpu->ps.u8[thread] & I ? 'I' : '-'
+ , cpu->ps.u8[thread] & Z ? 'Z' : '-'
+ , cpu->ps.u8[thread] & C ? 'C' : '-');
wprintw(scr, ", inst: ");
}
@@ -107,7 +111,7 @@ void disasm(struct sux *cpu, uint8_t lines, uint8_t opcode, uint8_t prefix, uint
if (subdbg) {
uint8_t ln = 33;
uint16_t line_idx = 0;
- uint32_t tmpad = 0x20237;
+ uint32_t tmpad = 0x20247;
int row, col;
uint8_t iscursor = 0;
union reg ptr;
diff --git a/opcode.h b/opcode.h
index 1c11ca5..4c5d585 100644
--- a/opcode.h
+++ b/opcode.h
@@ -17,7 +17,7 @@
#define V (1 << 6) /* oVerflow flag. */
#define N (1 << 7) /* Negative flag. */
-extern uint8_t get_addrsize(uint8_t prefix, uint8_t addrmode);
+/*extern uint8_t get_addrsize(uint8_t prefix, uint8_t addrmode);*/
extern char *showbits(uint64_t value, uint8_t bitnum, uint8_t dbg);
/* reg_expr, and val_expr are the arithmetic expressions
diff --git a/programs/sub-suite/declare.s b/programs/sub-suite/declare.s
index 7b419e2..5828fdb 100644
--- a/programs/sub-suite/declare.s
+++ b/programs/sub-suite/declare.s
@@ -312,6 +312,10 @@ t_str:
t_sym:
.res 8
+; First token.
+toks:
+ .res 8
+
; Current token.
ctok:
.res 8
@@ -320,6 +324,10 @@ ctok:
ltok:
.res 8
+; First line.
+lines:
+ .res 8
+
; Current line.
cline:
.res 8
@@ -385,9 +393,19 @@ symbol:
fixup:
.res 8
+; Line number.
+linenum:
+ .res 4
+ln:
+ .res 4
+
+; Is line number flag.
+islinenum:
+ .res 1
+
; ROM data declarations.
-.org $A000
+.org $C000
; String Literals/Constants.
;tok:
; .byte "dab"
@@ -409,8 +427,8 @@ made:
author:
.byte "mr b0nk 500"
-string2:
- .byte "You typed, "
+;string2:
+; .byte "You typed, "
asm_name:
.byte "SuBAsm"
diff --git a/programs/sub-suite/lexer.s b/programs/sub-suite/lexer.s
index fc47f10..9c3cb87 100644
--- a/programs/sub-suite/lexer.s
+++ b/programs/sub-suite/lexer.s
@@ -5,6 +5,7 @@ lex:
ldx #0 ; Reset X.
txa ; Reset A.
txy ; Reset Y.
+ sty.d ln ; Reset the temp line number.
sty.q idx0 ; Clear the first index.
sty.q idx1 ; Clear the second index.
sty.q idx2 ; Clear the third index.
@@ -13,19 +14,74 @@ lex:
sty.q t_str ; Clear the token string.
sty.q t_sym ; Clear the token symbol.
sty regb ; Clear the isop flag.
+ sty islinenum ; Clear the islinenum flag.
+; jsr init_lex ; Initialize the lexeme buffer.
+;@checklnum:
; lda (ptr), y ; Get a character from the line.
; pha ; Preserve the character.
; jsr isdigit ; Is this character a digit?
; pla ; Get the character back.
+; bne @checkidx ; No, so start checking the index.
+; pha ; Preserve the character.
+; jsr isdelm ; Yes, so get the delimiter type.
+; and #$10 ; Is this character whitespace?
+; pla ; Get the character back.
+; beq @checkidx ; Yes, so start checking the index.
+; sta (ptr3), y ; No, so copy the character into the lexeme buffer.
+; iny ; Increment the string index.
+; bra @checklnum ; Keep looping.
+;@checkidx:
+; sty.q idx0 ; Set the first index to the string index.
+; sty islinenum ; Set the islinenum flag to the string index.
+; tya ; Is the string index non-zero?
+; beq @nolnum ; No, so treat it as a completly new line.
+; and #0 ; Yes, so terminate the lexeme buffer.
+; sta (ptr3), y ;
+; lda.q ptr3 ; Setup arguments for strtoull.
+; pha.q ;
+; and #0 ; Reset A.
+; lda #10 ; Set the base to 10.
+; pha ;
+; jsr strtoull ;
+; sta.d ln ; Set the temp line number to the converted value.
+; pla ; Cleanup the argument frame.
+; pla.q ;
+; and #0 ; Reset A.
+; bra @getline ; Start getting the tokenized line.
+;@nolnum:
+; lda.d linenum ; Get the global line number.
+; sta.d ln ; Set the temp line number to to global line number.
+; and #0 ; Reset A.
+; sta.q cline ; Reset the current line pointer.
;@getline:
-; ldb #1 ; Set the second pointer
-; lda.q lline ; to the last line.
+; tay ; Reset Y.
+; lda.q cline ; Is the current line NULL?
+; bne @linepc ; No, so set the assembler's program counter to the line's address.
+; lda #ln ; Yes, so create a new tokenized line.
+; jsr malloc ;
+; sta.q cline ; Set the current line to the new tokenized line.
+; lda.q lline ; Is the last line NULL?
+; beq @firstline ; Yes, so set the first line.
+;@nextlline:
+; ldb #1 ; No, so set the second pointer to the last line.
+; jsr set_ptr ;
+; ldy #ln.next ; Set the next last line to the current line.
+; lda.q cline ;
+; sta.q (ptr2), y ;
+; bra @initline ; Initialize the line.
+;@firstline:
+; lda.q cline ; Set the first line to the current line.
+; sta.q lines ;
+;@initline:
+; ldb #1 ; Set the second pointer to the current line.
; jsr set_ptr ;
-; ldy #ln.next ; Set the index to the next line pointer.
-; lda.q (ptr2), y ; Get the next line.
-; jsr set_ptr ; Set the second pointer to the next line.
-; sta.q cline ; Make it the current line.
; and #0 ; Reset A.
+; ldy #ln.next ; Reset the next line.
+; sta.q (ptr2), y ;
+; ldy #ln.tok ; Reset the token.
+; sta.q (ptr2), y ;
+; ldy #ln.bline ; Reset the number of blank lines.
+; sta.w (ptr2), y ;
; tay ; Reset Y.
@loop:
ldy.w idx0 ; Get the string index.
@@ -255,8 +311,18 @@ ptok_dqu:
lda #TOK_DQUOT ; Set the lexeme type to TOK_DQUOT.
sta lex_type ;
sta t_id ; Also set the token ID to TOK_DQUOT.
- lda.d ptr3 ; Get the address of the lexeme buffer.
+; lda.d ptr3 ; Get the address of the lexeme buffer.
+ lda.q idx1 ; Get the index of the lexeme buffer.
+ inc ; Increment it by one to get the size.
+ jsr malloc ; Make a new string.
+ ldb.q ptr3 ; Get the address of the lexeme buffer.
+ ldy.q idx1 ; Get the size of the lexeme buffer + 1.
+ iny ;
+ jsr memcpy ; Copy the string in the lexeme buffer into the new string.
sta.q t_str ; Save it in the token string.
+ and #0 ; Reset A.
+ tab ; Reset B.
+ ldy.q idx0 ; Get the string index back.
@end:
jsr make_tok ; Create the token.
rts ; End of parse_ptok.
@@ -272,8 +338,17 @@ ptok_squ:
lda #TOK_SQUOT ; Set the lexeme type to TOK_SQUOT.
sta lex_type ;
sta t_id ; Also set the token ID to TOK_SQUOT.
- lda.d ptr3 ; Get the address of the lexeme buffer.
+ lda.q idx1 ; Get the index of the lexeme buffer.
+ inc ; Increment it by one to get the size.
+ jsr malloc ; Make a new string.
+ ldb.q ptr3 ; Get the address of the lexeme buffer.
+ ldy.q idx1 ; Get the size of the lexeme buffer + 1.
+ iny ;
+ jsr memcpy ; Copy the string in the lexeme buffer into the new string.
sta.q t_str ; Save it in the token string.
+ and #0 ; Reset A.
+ tab ; Reset B.
+ ldy.q idx0 ; Get the string index back.
@end:
jsr make_tok ; Create the token.
rts ; End of parse_ptok.
@@ -291,8 +366,17 @@ ptok_scol:
lda #TOK_SCOLN ; Set the lexeme type to TOK_SCOLN.
sta lex_type ;
sta t_id ; Also set the token ID to TOK_SCOLN.
- lda.d ptr3 ; Get the address of the lexeme buffer.
+ lda.q idx1 ; Get the index of the lexeme buffer.
+ inc ; Increment it by one to get the size.
+ jsr malloc ; Make a new string.
+ ldb.q ptr3 ; Get the address of the lexeme buffer.
+ ldy.q idx1 ; Get the size of the lexeme buffer + 1.
+ iny ;
+ jsr memcpy ; Copy the string in the lexeme buffer into the new string.
sta.q t_str ; Save it in the token string.
+ and #0 ; Reset A.
+ tab ; Reset B.
+ ldy.q idx0 ; Get the string index back.
@end:
jsr make_tok ; Create the token.
rts ; End of parse_ptok.
diff --git a/programs/sub-suite/libc.s b/programs/sub-suite/libc.s
index 18c10db..74ad654 100644
--- a/programs/sub-suite/libc.s
+++ b/programs/sub-suite/libc.s
@@ -508,3 +508,34 @@ free:
plb.q ; Restore B.
pla.q ; Restore A.
rts ; End of free.
+
+
+; memcpy: memory to memory copy.
+; Input: A = Destination pointer. B = Source pointer. Y = Number of bytes to copy.
+; Output: A = Destination pointer.
+; Caller preserved registers: none.
+; Callie preserved registers: none.
+
+memcpy:
+ pha.q ; Preserve the return value.
+ pha.q ; Push the destination pointer on the stack.
+ phb.q ; Push the source pointer on the stack.
+ phy.q ; Push the size on the stack.
+ and #0 ; Reset A.
+ tab ; Reset B.
+ cpy #0 ; Is the size zero?
+ beq @end ; Yes, so we're done.
+@loop:
+ lda (sp+9) ; Get a byte from the source.
+ sta (sp+17) ; Copy it to the destination.
+ inc.q sp+9 ; Increment the source pointer.
+ inc.q sp+17 ; Increment the destination pointer.
+ dey ; Decrement the size.
+ beq @end ; The size is zero, so we're done.
+ bra @loop ; Keep looping.
+@end:
+ pla.q ; Clean up the stack frame.
+ pla.q ;
+ pla.q ;
+ pla.q ; Restore the return value.
+ rts ; End of memcpy.
diff --git a/programs/sub-suite/subeditor.s b/programs/sub-suite/subeditor.s
index 2676a93..bec3f41 100644
--- a/programs/sub-suite/subeditor.s
+++ b/programs/sub-suite/subeditor.s
@@ -364,7 +364,7 @@ cmd_cpy:
sta (ptr2), y ; Copy one byte from the screen buffer, to the command buffer.
inx ; Increment the command buffer index.
ply.w ; Get back the screen index.
- cpx.w #$3FF ; Are we at the end of the command buffer?
+ cpx.w #CMDSIZE ; Are we at the end of the command buffer?
bcs @end ; Yes, so we're done.
iny ; No, so increment the screen index.
inb ; Increment the byte count.
@@ -579,7 +579,7 @@ clr_scr:
lda.q buffer ; Set the array to be cleared to the screen buffer.
jsr clr_arr ; Clear the screen buffer.
; tay ;
-; lda.w #$3FF ; Set the clear count to $3FF.
+; lda.w #CMDSIZE ; Set the clear count to CMDSIZE.
; sta.w scr_ptr ;
; lda.d #cmd_buf ; Set the array to be cleared to the command buffer.
; jsr clr_arr ; Clear the screen buffer.
diff --git a/programs/sub-suite/subsuite.s b/programs/sub-suite/subsuite.s
index 0cfad1e..d28b4f2 100644
--- a/programs/sub-suite/subsuite.s
+++ b/programs/sub-suite/subsuite.s
@@ -17,7 +17,7 @@
.qword reset
a
;l a
-;.org $8FA0
+;.org reset
;v
;q
d
diff --git a/sux.c b/sux.c
index adca16f..f064cee 100644
--- a/sux.c
+++ b/sux.c
@@ -1,4 +1,5 @@
#include "sux.h"
+/*#include "microcode.h"*/
#include <assert.h>
#if getclk
@@ -44,101 +45,8 @@ struct suxthr {
#if bench
double ipc;
-#endif
-inline uint8_t get_addrsize(uint8_t prefix, uint8_t addrmode) {
- uint8_t id = (prefix & 0x0C) >> 2;
- switch (addrmode) {
- case ZM:
- switch (id) {
- case 2: return 5;
- case 3: return 3;
- case 1: return 2;
- case 0: return 0;
- }
- break;
- case ABS:
- switch (id) {
- case 3: return 7;
- case 2: return 6;
- case 1: return 4;
- case 0: return 1;
- }
- break;
- }
- return 0;
-}
-static inline uint8_t isrw(uint8_t opcode) {
- switch (opcode) {
- case STA_AB: /* STA Absolute. */
- case STA_Z: /* STA Zero Matrix. */
- case STA_ZX: /* STA Zero Matrix, Indexed with X. */
- case STA_ZY: /* STA Zero Matrix, Indexed with Y. */
- case STA_IN: /* STA Indirect. */
- case STA_IX: /* STA Indexed Indirect. */
- case STA_IY: /* STA Indirect Indexed. */
- case STY_AB: /* STY Absolute. */
- case STY_Z: /* STY Zero Matrix. */
- case STY_IN: /* STY Indirect. */
- case STX_AB: /* STX Absolute. */
- case STX_Z: /* STX Zero Matrix. */
- case STX_IN: /* STX Indirect. */
- case STB_AB: /* STB Absolute. */
- case STB_Z: /* STB Zero Matrix. */
- case STB_ZX: /* STB Zero Matrix, Indexed with X. */
- case STB_ZY: /* STB Zero Matrix, Indexed with Y. */
- case STB_IN: /* STB Indirect. */
- case STB_IX: /* STB Indexed Indirect. */
- case STB_IY: /* STB Indirect Indexed. */
- case INC_AB: /* INC Absolute. */
- case INC_Z: /* INC Zero Matrix. */
- case DEC_AB: /* DEC Absolute. */
- case DEC_Z: /* DEC Zero Matrix. */
- return 0; /* Writing. */
- default:
- return 1; /* Reading. */
- }
-}
-static inline uint8_t isread(uint8_t opcode) {
- switch (opcode) {
- case LDA_IMM: /* LDA Immediate. */
- case LDA_AB: /* LDA Absolute. */
- case LDA_Z: /* LDA Zero Matrix. */
- case LDA_ZX: /* LDA Zero Matrix, Indexed with X. */
- case LDA_ZY: /* LDA Zero Matrix, Indexed with Y. */
- case LDA_IN: /* LDA Indirect. */
- case LDA_IX: /* LDA Indexed Indirect. */
- case LDA_IY: /* LDA Indirect Indexed. */
- case LDB_IMM: /* LDB Immediate. */
- case LDB_AB: /* LDB Absolute. */
- case LDB_Z: /* LDB Zero Matrix. */
- case LDB_ZX: /* LDB Zero Matrix, Indexed with X. */
- case LDB_ZY: /* LDB Zero Matrix, Indexed with Y. */
- case LDB_IN: /* LDB Indirect. */
- case LDB_IX: /* LDB Indexed Indirect. */
- case LDB_IY: /* LDB Indirect Indexed. */
- case LDY_IMM: /* LDY Immediate. */
- case LDY_AB: /* LDY Absolute. */
- case LDY_Z: /* LDY Zero Matrix. */
- case LDY_IN: /* LDY Indirect. */
- case LDX_IMM: /* LDX Immediate. */
- case LDX_AB: /* LDX Absolute. */
- case LDX_Z: /* LDX Zero Matrix. */
- case LDX_IN: /* LDX Indirect. */
- case JMP_AB: /* JMP Absolute. */
- case JMP_Z: /* JMP Zero Matrix. */
- case JMP_IN: /* JMP Indirect. */
- case JSR_IN: /* JSR Indirect. */
- case JSR_AB: /* Jump to SubRoutine. */
- case JSR_Z: /* JSR Zero Matrix. */
- return 0;
- default:
- return 1;
- }
-}
-
-#if bench
void stop_timer() {
time_done = 1;
}
@@ -195,6 +103,21 @@ void *run(void *args) {
#if bench
start_timer(1, 0);
#endif
+ /*ucode uc;
+ uc.upc = 0;
+ uc.usp = 0xFF;
+ uc.alu_a = 0;
+ uc.alu_b = 0;
+ uc.dbus = 0;
+ for (int i = 0; i < AGU_IDX_CNT; uc.agu_idx[i++] = 0);
+ uc.agu_dben = 0;
+ uc.agu_oplen = 0;
+ uc.mdr = 0;
+ uc.mar = 0;
+ uc.ir = 0;
+ uc.itr = 0;
+ uc.clk = 0;
+ struct sux uc_test;*/
for (;;) {
#if !bench
if (end) {
@@ -248,6 +171,7 @@ void *run(void *args) {
value.u64 = read_value(cpu, 0, address.u64, size, 1, check_io);
}
}
+ /*decode_microinst(&uc, &uc_test, prefix, 0);*/
switch (opcode) {
case CPS_IMP: /* Clear Processor Status. */
cpu->ps.u64 = 0;
@@ -654,6 +578,35 @@ int main(int argc, char **argv) {
int result;
uint16_t vec = 0xFFC0;
uint8_t offset;
+ /*for (int i = 0; i < 4096; i++) {
+ for (int j = 0; j < RW_UNITS; j++) {
+ mucode[i].ui.ru[j].type = rand();
+ mucode[i].ui.wu[j].type = rand();
+ }
+ mucode[i].ui.imm = rand();
+
+ mucode[i].ui.agu_sig.prefix = rand();
+ mucode[i].ui.agu_sig.ind = rand();
+ mucode[i].ui.agu_sig.ind_type = rand();
+ mucode[i].ui.agu_sig.zm = rand();
+ mucode[i].ui.agu_sig.idx_sub = rand();
+
+ mucode[i].ui.sig.mread = rand();
+ mucode[i].ui.sig.mwrite = rand();
+ mucode[i].ui.sig.inv_b = rand();
+ mucode[i].ui.sig.c_in = rand();
+ mucode[i].ui.sig.fetch = rand();
+ mucode[i].ui.sig.set_nvzc = rand();
+ mucode[i].ui.sig.rw_en = rand();
+
+ mucode[i].ui.is_jmp = rand();
+ mucode[i].ui.jmp_type = rand();
+ mucode[i].ui.cond_type = rand();
+ mucode[i].ui.cond_reg = rand();
+ mucode[i].ui.jmp_addr = rand();
+
+ for (int j = 0; j < sizeof(uinst); mucode[i].u8[j++] = (uint8_t)rand());
+ }*/
for (int i = 0; i < THREADS; i++) {
thr[i].sx.sp = (i << 16) | 0xFFFF;
offset = (i) ? ((i-1) << 3) : 0;
@@ -662,15 +615,7 @@ int main(int argc, char **argv) {
thr[i].sx.b = 0;
thr[i].sx.x = 0;
thr[i].sx.y = 0;
- thr[i].sx.pc = (uint64_t)addr[vec+0+offset]
- | (uint64_t)addr[vec+1+offset] << 8
- | (uint64_t)addr[vec+2+offset] << 16
- | (uint64_t)addr[vec+3+offset] << 24
- | (uint64_t)addr[vec+4+offset] << 32
- | (uint64_t)addr[vec+5+offset] << 40
- | (uint64_t)addr[vec+6+offset] << 48
- | (uint64_t)addr[vec+7+offset] << 56;
-
+ thr[i].sx.pc = read_value(&thr[i].sx, 0, vec+offset, 7, 0, 0);
thr[i].th = i;
#if !IO
inst[i] = 0;
diff --git a/sux.h b/sux.h
index 5bfdb44..f719b03 100644
--- a/sux.h
+++ b/sux.h
@@ -55,6 +55,98 @@ extern void io(uint64_t address, uint8_t rw);
extern void init_scr();
+static inline uint8_t get_addrsize(uint8_t prefix, uint8_t addrmode) {
+ uint8_t id = (prefix & 0x0C) >> 2;
+ switch (addrmode) {
+ case ZM:
+ switch (id) {
+ case 2: return 5;
+ case 3: return 3;
+ case 1: return 2;
+ case 0: return 0;
+ }
+ break;
+ case ABS:
+ switch (id) {
+ case 3: return 7;
+ case 2: return 6;
+ case 1: return 4;
+ case 0: return 1;
+ }
+ break;
+ }
+ return 0;
+}
+
+static inline uint8_t isrw(uint8_t opcode) {
+ switch (opcode) {
+ case STA_AB: /* STA Absolute. */
+ case STA_Z: /* STA Zero Matrix. */
+ case STA_ZX: /* STA Zero Matrix, Indexed with X. */
+ case STA_ZY: /* STA Zero Matrix, Indexed with Y. */
+ case STA_IN: /* STA Indirect. */
+ case STA_IX: /* STA Indexed Indirect. */
+ case STA_IY: /* STA Indirect Indexed. */
+ case STY_AB: /* STY Absolute. */
+ case STY_Z: /* STY Zero Matrix. */
+ case STY_IN: /* STY Indirect. */
+ case STX_AB: /* STX Absolute. */
+ case STX_Z: /* STX Zero Matrix. */
+ case STX_IN: /* STX Indirect. */
+ case STB_AB: /* STB Absolute. */
+ case STB_Z: /* STB Zero Matrix. */
+ case STB_ZX: /* STB Zero Matrix, Indexed with X. */
+ case STB_ZY: /* STB Zero Matrix, Indexed with Y. */
+ case STB_IN: /* STB Indirect. */
+ case STB_IX: /* STB Indexed Indirect. */
+ case STB_IY: /* STB Indirect Indexed. */
+ case INC_AB: /* INC Absolute. */
+ case INC_Z: /* INC Zero Matrix. */
+ case DEC_AB: /* DEC Absolute. */
+ case DEC_Z: /* DEC Zero Matrix. */
+ return 0; /* Writing. */
+ default:
+ return 1; /* Reading. */
+ }
+}
+static inline uint8_t isread(uint8_t opcode) {
+ switch (opcode) {
+ case LDA_IMM: /* LDA Immediate. */
+ case LDA_AB: /* LDA Absolute. */
+ case LDA_Z: /* LDA Zero Matrix. */
+ case LDA_ZX: /* LDA Zero Matrix, Indexed with X. */
+ case LDA_ZY: /* LDA Zero Matrix, Indexed with Y. */
+ case LDA_IN: /* LDA Indirect. */
+ case LDA_IX: /* LDA Indexed Indirect. */
+ case LDA_IY: /* LDA Indirect Indexed. */
+ case LDB_IMM: /* LDB Immediate. */
+ case LDB_AB: /* LDB Absolute. */
+ case LDB_Z: /* LDB Zero Matrix. */
+ case LDB_ZX: /* LDB Zero Matrix, Indexed with X. */
+ case LDB_ZY: /* LDB Zero Matrix, Indexed with Y. */
+ case LDB_IN: /* LDB Indirect. */
+ case LDB_IX: /* LDB Indexed Indirect. */
+ case LDB_IY: /* LDB Indirect Indexed. */
+ case LDY_IMM: /* LDY Immediate. */
+ case LDY_AB: /* LDY Absolute. */
+ case LDY_Z: /* LDY Zero Matrix. */
+ case LDY_IN: /* LDY Indirect. */
+ case LDX_IMM: /* LDX Immediate. */
+ case LDX_AB: /* LDX Absolute. */
+ case LDX_Z: /* LDX Zero Matrix. */
+ case LDX_IN: /* LDX Indirect. */
+ case JMP_AB: /* JMP Absolute. */
+ case JMP_Z: /* JMP Zero Matrix. */
+ case JMP_IN: /* JMP Indirect. */
+ case JSR_IN: /* JSR Indirect. */
+ case JSR_AB: /* Jump to SubRoutine. */
+ case JSR_Z: /* JSR Zero Matrix. */
+ return 0;
+ default:
+ return 1;
+ }
+}
+
static void *memcopy(void *restrict dst, const void *restrict src, unsigned int n) {
#if copy64
uint64_t *d = dst;