From 8aa8586b03568d3a3d6eba39269a1b79510bc835 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Tue, 6 Oct 2020 08:02:23 -0400 Subject: - Made the stack pointer 64 bit, rather than 16 bit. This is to allow for making the stack bigger for anything that needs to change the size of it. - Made the SuB Suite set the stack pointer to the end of the usable RAM, and allow for changing the stack size. In this case, the size of the stack is currently set to 192K, with the end of the heap being just below the stack. --- sux.h | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'sux.h') diff --git a/sux.h b/sux.h index 744a2cc..5bfdb44 100644 --- a/sux.h +++ b/sux.h @@ -141,8 +141,8 @@ static inline void write_value(struct sux *cpu, uint64_t value, uint64_t address static inline uint64_t offset_addr(struct sux *cpu, uint64_t offset, uint8_t size, uint8_t inc_clk, uint8_t prefix) { uint64_t of; switch (prefix >> 6) { - case 1: of = ((cpu->stk_st << 16) | cpu->sp); break; - case 2: of = cpu->pc ; break; + case 1: of = cpu->sp; break; + case 2: of = cpu->pc; break; } #if getclk cpu->clk += inc_clk; @@ -278,30 +278,19 @@ static inline uint64_t adc(struct sux *cpu, uint64_t reg, uint64_t value, uint8_ return sum; } -static inline uint64_t transfer(struct sux *cpu, uint64_t src, uint64_t value, uint8_t opcode, uint8_t prefix, uint8_t thread) { - switch (opcode) { - case TXS_IMM: - if (prefix == 0x13 && (value == thread+1 || value > 8)) { - cpu->stk_st = value & 0xFF; - cpu->stk_st += value << 16; - cpu->pc+=2; - } - default: break; - } +static inline uint64_t transfer(struct sux *cpu, uint64_t src, uint64_t value, uint8_t thread) { setflag(src == 0, Z); setflag(src >> 63, N); return src; } static inline void push(struct sux *cpu, uint64_t value, uint8_t size, uint8_t thread) { - uint64_t sbr = (cpu->stk_st << 16); - write_value(cpu, value, (sbr+cpu->sp)-size, size, 1, 0); + write_value(cpu, value, cpu->sp-size, size, 1, 0); cpu->sp -= size+1; } static inline uint64_t pull(struct sux *cpu, uint8_t size, uint8_t thread) { - uint64_t sbr = (cpu->stk_st << 16); - uint64_t value = read_value(cpu, 0, sbr+cpu->sp+1, size, 1, 0); + uint64_t value = read_value(cpu, 0, cpu->sp+1, size, 1, 0); cpu->sp += size+1; return value; } -- cgit v1.2.3-13-gbd6f