From 96ae48f8a79f33cff0a89fac211b6862866e1a44 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Mon, 5 Oct 2020 08:47:08 -0400 Subject: - Added a routine for testing the SuB Suite's implementation of free(), although it's commented out. - Removed the sbc() function from the emulator, since sbc can be done by just inverting the second operand of adc. --- programs/sub-suite/subeditor.s | 26 ++++++++++++++++++++++++++ sux.c | 2 +- sux.h | 8 -------- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/programs/sub-suite/subeditor.s b/programs/sub-suite/subeditor.s index 7e124a2..d98d068 100644 --- a/programs/sub-suite/subeditor.s +++ b/programs/sub-suite/subeditor.s @@ -12,6 +12,7 @@ reset: tyx ; Reset X. jsr init_heap ; Initialize the heap. jsr init_tables ; Initialize the main tables. +; jsr test_free ; jsr clr_scr ; Clear the screen. jsr pnt_strt ; Print the starting message. bra start ; Goto the start of the main program. @@ -48,6 +49,30 @@ init_tables: rts ; End of init_tables. +;test_free: +; inc step ; +; lda.q bitabl ; +; jsr free ; +; lda.q buffer ; +; jsr free ; +; and #0 ; Reset A. +; lda.w #LWSIZE ; Allocate LWSIZE bytes of RAM for the linewrap table. +; jsr malloc ; +; sta.q bitabl ; +; lda.q cmd_buf ; +; jsr free ; +; and #0 ; Reset A. +; lda.w #SCRSIZE ; Allocate SCRSIZE bytes of RAM for the screen buffer. +; jsr malloc ; +; sta.q buffer ; +; and #0 ; Reset A. +; lda.w #CMDSIZE ; Allocate CMDSIZE bytes of RAM for the command buffer. +; jsr malloc ; +; sta.q cmd_buf ; +; and #0 ; Reset A. +; rts ; End of test_free. + + clr_arr: phb ; Preserve whatever was in B. ldb #0 ; Clear B. @@ -78,6 +103,7 @@ clr_arr: plb ; Get whatever was in the B register, back. rts ; End of clr_arr. + pnt_strt: lda.w #ed_name ; Print the name of the editor. jsr print_str ; diff --git a/sux.c b/sux.c index daabdc2..acd834e 100644 --- a/sux.c +++ b/sux.c @@ -286,7 +286,7 @@ void *run(void *args) { case SBC_IMM: /* SBC Immediate. */ case SBC_AB: /* SBC Absolute. */ case SBC_Z: /* SBC Zero Matrix. */ - cpu->a = sbc(cpu, cpu->a, value.u64, thread); + cpu->a = adc(cpu, cpu->a, ~value.u64, thread); break; case PLP_IMP: cpu->ps.u8[thread] = pull(cpu, 0, thread); break; /* PuLl Processor status from stack. */ case PLA_IMP: cpu->a = pull(cpu, size, thread); break; /* PuLl Accumulator from stack. */ diff --git a/sux.h b/sux.h index 509a6bc..9004c74 100644 --- a/sux.h +++ b/sux.h @@ -277,14 +277,6 @@ static inline uint64_t adc(struct sux *cpu, uint64_t reg, uint64_t value, uint8_ setflag((sum < value), C); return sum; } -static inline uint64_t sbc(struct sux *cpu, uint64_t reg, uint64_t value, uint8_t thread) { - uint64_t sum = reg-value-!getflag(C); - setflag(sum == 0, Z); - setflag(sum >> 63, N); - setflag(((reg^value) >> 63) && ((reg^sum) >> 63), V); - setflag((sum < value), C); - 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) { -- cgit v1.2.3-13-gbd6f