From a4670b1edabef51d2f746b750be4bc4e1eb2d7b9 Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Sat, 21 Jun 2014 14:07:47 -0700 Subject: [PATCH] Use CPP macro for duplicate assembly --- src/misc.c | 1 + src/x86/cpu-regs.h | 6 ++++++ src/x86/cpu.S | 5 +---- src/x86/glue-prologue.h | 4 +--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/misc.c b/src/misc.c index aa4bbd32..6d630ef3 100644 --- a/src/misc.c +++ b/src/misc.c @@ -54,6 +54,7 @@ GLUE_BANK_READ(iie_read_slotx,base_cxrom) uint32_t softswitches; +const uint8_t *base_vmem = apple_ii_64k[0]; uint8_t *base_ramrd; uint8_t *base_ramwrt; uint8_t *base_textrd; diff --git a/src/x86/cpu-regs.h b/src/x86/cpu-regs.h index 8b83eb8d..585c1a1d 100644 --- a/src/x86/cpu-regs.h +++ b/src/x86/cpu-regs.h @@ -26,6 +26,12 @@ #define X86_CF_Bit 0x0 /* x86 carry */ #define X86_AF_Bit 0x4 /* x86 adj (nybble carry) */ +#define RestoreAltZP \ + /* Apple //e set stack point to ALTZP (or not) */ \ + movLQ SN(base_stackzp), _XAX; \ + subLQ SN(base_vmem), _XAX; \ + orLQ _XAX, SP_Reg_X; + #if __LP64__ # define SZ_PTR 8 # define ROR_BIT 63 diff --git a/src/x86/cpu.S b/src/x86/cpu.S index 93add8eb..114b1538 100644 --- a/src/x86/cpu.S +++ b/src/x86/cpu.S @@ -2119,10 +2119,7 @@ E(cpu65_run) movb SN(cpu65_current)+5, Y_Reg movb SN(cpu65_current)+6, SP_Reg_L #ifdef APPLE2_VM - // Apple //e machine specific set stack point to ALTZP (or not) - movLQ SN(base_stackzp), _XAX - subLQ $SN(apple_ii_64k), _XAX - orLQ _XAX, SP_Reg_X + RestoreAltZP #endif jmp continue1 diff --git a/src/x86/glue-prologue.h b/src/x86/glue-prologue.h index 6381540c..762d99ea 100644 --- a/src/x86/glue-prologue.h +++ b/src/x86/glue-prologue.h @@ -111,9 +111,7 @@ E(func) pushLQ XY_Reg_X; \ #define GLUE_C_READ_ALTZP(FUNC) _GLUE_C_READ(FUNC, \ pushLQ _XAX; \ andLQ $0xFFFF, SP_Reg_X; \ - movLQ SN(base_stackzp), _XAX; \ - subLQ $SN(apple_ii_64k), _XAX; \ - orLQ _XAX, SP_Reg_X; \ + RestoreAltZP \ popLQ _XAX; \ )