From cbad8aabbc82efbe7a49572a2da74224ae9c9f85 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sun, 1 Dec 2019 17:40:41 -0500 Subject: Added the ability to disable the prefix byte. Any instructions that either have a register size of 8 bits, use implied addressing, or branch can save a byte by disabling the prefix byte. It does this by checking if the first three bits are all set to 1. If true, then it will treat it as a prefix byte, otherwise, it will treat it as an opcode. --- opcode.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'opcode.c') diff --git a/opcode.c b/opcode.c index 0bee207..4484466 100644 --- a/opcode.c +++ b/opcode.c @@ -12,8 +12,9 @@ void setps(struct sux *cpu, uint8_t thread) { void adc(struct sux *cpu, uint64_t adr, uint8_t thread, uint8_t regsize) { uint64_t value; value = (uint64_t)addr[adr]; - if (regsize >= 2) + if (regsize >= 2) { value += (uint64_t)addr[adr+1] << 8; + } if (regsize >= 4) { value += (uint64_t)addr[adr+2] << 16; value += (uint64_t)addr[adr+3] << 24; @@ -385,6 +386,7 @@ uint64_t absaddr(struct sux *cpu, uint8_t thread) { | (uint64_t)addr[cpu->pc[thread]+6] << 48 | (uint64_t)addr[cpu->pc[thread]+7] << 56; cpu->pc[thread]+=8; + ibcount+=8; clk++; return adr; } @@ -395,7 +397,11 @@ uint32_t zeromtx(struct sux *cpu, uint8_t thread) { | (uint32_t)addr[cpu->pc[thread]+2] << 16 | (uint32_t)addr[cpu->pc[thread]+3] << 24; cpu->pc[thread]+=4; - clk++; + ibcount+=4; + if (ibcount > 8) { + clk++; + ibcount = 0; + } return adr; } @@ -406,7 +412,11 @@ uint32_t zeromx(struct sux *cpu, uint8_t thread) { | (uint32_t)addr[cpu->pc[thread]+3] << 24; adr += cpu->x[thread]; cpu->pc[thread]+=4; - clk++; + ibcount+=4; + if (ibcount > 8) { + clk++; + ibcount = 0; + } return adr; } @@ -417,6 +427,10 @@ uint32_t zeromy(struct sux *cpu, uint8_t thread) { | (uint32_t)addr[cpu->pc[thread]+3] << 24; adr += cpu->y[thread]; cpu->pc[thread]+=4; - clk++; + ibcount+=4; + if (ibcount > 8) { + clk++; + ibcount = 0; + } return adr; } -- cgit v1.2.3-13-gbd6f