summaryrefslogtreecommitdiff
path: root/opcode.h
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2019-11-30 19:57:46 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2019-11-30 19:57:46 -0500
commitca89989d057a19b647514656d96d00ff23be9640 (patch)
tree1259b343d60680a4354a1a54b90d0d7418af770b /opcode.h
parent10ec62e8025eb43d1a096fb0962049670c3c148c (diff)
Start work on rev2 of Sux.
Added a prefix byte to tell the CPU certain information such as, how many bytes to load into the registers, or what ISA extension we want to use. I also added an assembly language monitor, so that I don't have to write stuff in machine code.
Diffstat (limited to 'opcode.h')
-rw-r--r--opcode.h37
1 files changed, 27 insertions, 10 deletions
diff --git a/opcode.h b/opcode.h
index 3b44e4b..d83b74c 100644
--- a/opcode.h
+++ b/opcode.h
@@ -79,7 +79,9 @@
#define DAY 0xD3 /* Decrement Accumulator, and Y register. */
#define DEX 0xD4 /* DEcrement X register. */
#define DAX 0xD5 /* Decrement Accumulator, and X register. */
+#define JSL 0xE0 /* Jump to Subroutine Long. */
#define NOP 0xE8 /* No OPeration. */
+#define RTL 0xF0 /* ReTurn from subroutine Long. */
#define BRK 0xF8 /* BReaK. */
#define C ((uint64_t)1 << 0)
@@ -94,6 +96,7 @@
struct sux;
uint8_t *addr; /* Address Space. */
+uint64_t clk; /* Clock cycles. */
struct sux {
uint64_t ps; /* The processor status register. */
@@ -105,6 +108,16 @@ struct sux {
};
+typedef struct {
+ char mnemonic[4];
+ uint8_t imm;
+ uint8_t abs;
+ uint8_t zm;
+ uint8_t zmy;
+ uint8_t zmx;
+ uint8_t impl;
+} opent;
+
static const char *opname[0x100] = {
OPNAME(CPS),
[ADC] = "ADC #",
@@ -227,17 +240,20 @@ static const char *opname[0x100] = {
OPNAME(IAY),
OPNAME(INX),
OPNAME(IAX),
+ [0xD0] = "JMP zm",
[DEC] = "DEC A",
OPNAME(DEY),
OPNAME(DAY),
OPNAME(DEX),
OPNAME(DAX),
+ OPNAME(JSL),
[0xE1] = "INC a",
[0xE2] = "CPY a",
[0xE3] = "INC zm",
[0xE4] = "CPX a",
[0xE5] = "CMP a",
OPNAME(NOP),
+ OPNAME(RTL),
[0xF1] = "DEC a",
[0xF2] = "CPY zm",
[0xF3] = "DEC zm",
@@ -246,16 +262,17 @@ static const char *opname[0x100] = {
OPNAME(BRK),
};
-extern void adc(struct sux *cpu, uint64_t adr, uint8_t thread);
-extern void sbc(struct sux *cpu, uint64_t adr, uint8_t thread);
-extern void mul(struct sux *cpu, uint64_t adr, uint8_t thread);
-extern void divd(struct sux *cpu, uint64_t adr, uint8_t thread);
+extern int asmmon();
+extern void adc(struct sux *cpu, uint64_t adr, uint8_t thread, uint8_t regsize);
+extern void sbc(struct sux *cpu, uint64_t adr, uint8_t thread, uint8_t regsize);
+extern void mul(struct sux *cpu, uint64_t adr, uint8_t thread, uint8_t regsize);
+extern void divd(struct sux *cpu, uint64_t adr, uint8_t thread, uint8_t regsize);
extern uint64_t and(struct sux *cpu, uint64_t value, uint8_t thread);
-extern void and_addr(struct sux *cpu, uint64_t* const reg, uint64_t adr, uint8_t thread);
+extern void and_addr(struct sux *cpu, uint64_t* const reg, uint64_t adr, uint8_t thread, uint8_t regsize);
extern uint64_t or(struct sux *cpu, uint64_t value, uint8_t thread);
-extern void or_addr(struct sux *cpu, uint64_t* const reg, uint64_t adr, uint8_t thread);
+extern void or_addr(struct sux *cpu, uint64_t* const reg, uint64_t adr, uint8_t thread, uint8_t regsize);
extern uint64_t xor(struct sux *cpu, uint64_t value, uint8_t thread);
-extern void xor_addr(struct sux *cpu, uint64_t* const reg, uint64_t adr, uint8_t thread);
+extern void xor_addr(struct sux *cpu, uint64_t* const reg, uint64_t adr, uint8_t thread, uint8_t regsize);
extern void rol(struct sux *cpu, uint64_t adr, uint8_t thread);
extern void ror(struct sux *cpu, uint64_t adr, uint8_t thread);
extern void lsl(struct sux *cpu, uint64_t adr, uint8_t thread);
@@ -266,11 +283,11 @@ extern void dec(struct sux *cpu, uint64_t *reg, uint8_t thread);
extern void dec_addr(struct sux *cpu, uint64_t adr, uint8_t thread);
extern void stt(struct sux *cpu, uint8_t value);
extern void ent(struct sux *cpu, uint8_t value);
-extern void ld(struct sux *cpu, uint64_t *reg, uint64_t adr, uint8_t thread);
-extern void st(struct sux *cpu, uint64_t *reg, uint64_t adr, uint8_t thread);
+extern void ld(struct sux *cpu, uint64_t *reg, uint64_t adr, uint8_t thread, uint8_t regsize);
+extern void st(struct sux *cpu, uint64_t *reg, uint64_t adr, uint8_t thread, uint8_t regsize);
extern void push(struct sux *cpu, uint8_t value);
extern uint8_t pull(struct sux *cpu);
-extern void cmp_addr(struct sux *cpu, uint64_t reg, uint64_t adr, uint8_t thread);
+extern void cmp_addr(struct sux *cpu, uint64_t reg, uint64_t adr, uint8_t thread, uint8_t regsize);
extern void cmp(struct sux *cpu, uint64_t reg1, uint64_t reg2, uint8_t thread);
extern void bfs(struct sux *cpu, uint8_t flag, uint64_t adr, uint8_t thread);
extern void bfc(struct sux *cpu, uint8_t flag, uint64_t adr, uint8_t thread);