diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2020-10-06 08:02:23 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2020-10-06 08:02:23 -0400 |
commit | 8aa8586b03568d3a3d6eba39269a1b79510bc835 (patch) | |
tree | b674ea424fd816fe4219b4423c2e3544b1ff58ce /sux.h | |
parent | 8c880c339000010260a927c3a0f28f9049b8a0b8 (diff) |
- 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.
Diffstat (limited to 'sux.h')
-rw-r--r-- | sux.h | 21 |
1 files changed, 5 insertions, 16 deletions
@@ -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; } |