diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2022-01-19 14:09:05 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2022-01-19 14:09:05 -0400 |
commit | 6d0e1d5754a2093ac16e6947231b6bd320c7de0a (patch) | |
tree | 43c7fa991e10618179718f62ebf769bbb22e4ad6 | |
parent | dbc0948d6df1dc87943bbc5fe44a909f9501386f (diff) |
sux.h: Add bitmasks for writing a value to memory.
-rw-r--r-- | sux.h | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -1792,7 +1792,7 @@ static /*inline*/ void exec_base_inst(struct sux *cpu, uint8_t opcode, uint8_t p #define inst(op, ext) \ static /*inline*/ void inst_##op(struct sux *cpu, uint8_t prefix, uint8_t size, int inc_pc, int inc_clk, uint8_t thread) { \ const unsigned int o8 = 0x##op / 32, o8m = 1 << (0x##op % 32); \ - const uint8_t rs = 1 << ((prefix >> 4) & 3); \ + const uint8_t rs = (1 << ((prefix >> 4) & 3)) - 1; \ uint64_t addr = 0, idx = 0, tmp = 0, tmp2 = 0; \ uint64_t dummy = 0, *reg = &dummy; \ int pre_idx = 0, mem_type = ZM; \ @@ -1808,6 +1808,7 @@ static /*inline*/ void inst_##op(struct sux *cpu, uint8_t prefix, uint8_t size, t(7, 0x00460160, 0x00460160, 0x00160160, 0x00160160, 0x01161360, 0x11165161, 0x11175161, 0x01171160) { addr = read_addr(cpu, prefix, inc_clk, mem_type, inc_pc) + idx; } /* Read address from memory. */ \ t(0, 0x01000000, 0x01000000, 0x04000400, 0x00000000, 0x00000000, 0x40000000, 0x40000000, 0x00000000) { pre_idx = 1; } /* Set pre-index flag, for indexed indirect. */ \ t(0, 0x07101210, 0x17101410, 0x14001400, 0x10001000, 0x10000000, 0x40000000, 0x40000000, 0x00000000) { addr = ind_idx_addr(cpu, prefix, inc_clk, ZM, inc_pc, idx, pre_idx); } /* Indirect addressing, with indexing. */ \ + t(7, 0x07561370, 0x17561570, 0x14161560, 0x10161160, 0x11161360, 0x51165161, 0x51175161, 0x01171160) { idx = 0; } /* Reset index. */ \ /* Load Source. */ \ t(0, 0x02220022, 0x03760576, 0x00320522, 0x00761166, 0x00660066, 0x00660066, 0x51665066, 0x00660066) { reg = &cpu->a; } /* Most operations use the accumulator as an operand */ \ t(0, 0x05540354, 0x04000000, 0x04000200, 0x02000000, 0x10000000, 0x51005000, 0x00000000, 0x04100110) { reg = &cpu->b; } /* ldb, stb, cpb, inb, deb, tba */ \ @@ -1821,6 +1822,8 @@ static /*inline*/ void inst_##op(struct sux *cpu, uint8_t prefix, uint8_t size, t(0, 0x00000000, 0x00000200, 0x02000210, 0x02000210, 0x02000000, 0x00000000, 0x00000000, 0x00000000) { tmp = *reg; } /* Mogrifying register. */ \ t(0, 0x00000000, 0x00000200, 0x00100310, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000) { ++tmp; } /* inc */ \ t(0, 0x00000000, 0x00000000, 0x02000000, 0x02100110, 0x02000000, 0x00000000, 0x00000000, 0x00000000) { --tmp; } /* dec */ \ + /* Store modified value into memory. */ \ + t(0, 0x00100000, 0x04101400, 0x00100100, 0x10100100, 0x01001000, 0x51005000, 0x51005000, 0x01001000) { write_value(cpu, tmp, addr, rs, inc_clk, 1); } \ } #undef ORTHO_1CC |