mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-26 00:29:27 +00:00
x86_64 target builds
This commit is contained in:
parent
126d049ffc
commit
c33cdb4b25
|
@ -17,10 +17,10 @@ AC_PROG_INSTALL
|
||||||
dnl ---------------------------------------------------------------------------
|
dnl ---------------------------------------------------------------------------
|
||||||
dnl Arch checks
|
dnl Arch checks
|
||||||
|
|
||||||
|
ASM_O="src/x86/glue.o src/x86/cpu.o"
|
||||||
arch=''
|
arch=''
|
||||||
case $target in
|
case $target in
|
||||||
x86_64-*-*)
|
x86_64-*-*)
|
||||||
ASM_O="src/x64/glue.o src/x64/cpu.o"
|
|
||||||
arch='x64'
|
arch='x64'
|
||||||
;;
|
;;
|
||||||
i?86-*-*)
|
i?86-*-*)
|
||||||
|
@ -31,6 +31,7 @@ case $target in
|
||||||
arch='x86'
|
arch='x86'
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
ASM_O=""
|
||||||
AC_MSG_ERROR([emulator does not presently support architecture $target])
|
AC_MSG_ERROR([emulator does not presently support architecture $target])
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -39,7 +40,6 @@ AM_CFLAGS="-std=gnu11 -Wall"
|
||||||
|
|
||||||
dnl double-check compilation for x86 target
|
dnl double-check compilation for x86 target
|
||||||
if test "$arch" = "x86" ; then
|
if test "$arch" = "x86" ; then
|
||||||
ASM_O="src/x86/glue.o src/x86/cpu.o"
|
|
||||||
my_save_cflags="$CFLAGS"
|
my_save_cflags="$CFLAGS"
|
||||||
AC_MSG_CHECKING([whether compiler supports x86 target])
|
AC_MSG_CHECKING([whether compiler supports x86 target])
|
||||||
case $host in
|
case $host in
|
||||||
|
|
|
@ -967,7 +967,7 @@ void init_lex (char *str, int size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WONT_EXECUTE 0
|
#define WONT_EXECUTE 0
|
||||||
static volatile int hack_warnings = (int)&hack_warnings;
|
static volatile void *hack_warnings = &hack_warnings;
|
||||||
if (hack_warnings == WONT_EXECUTE) {
|
if (hack_warnings == WONT_EXECUTE) {
|
||||||
// flex defines these, but we don't use 'em ...
|
// flex defines these, but we don't use 'em ...
|
||||||
char hack[2];
|
char hack[2];
|
||||||
|
|
|
@ -21,9 +21,39 @@
|
||||||
#define EffectiveAddr %di /* Effective address */
|
#define EffectiveAddr %di /* Effective address */
|
||||||
|
|
||||||
#if __LP64__
|
#if __LP64__
|
||||||
# error not ready
|
# define SZ_PTR 8
|
||||||
|
# define _XBP %rbp /* x86_64 base pointer */
|
||||||
|
# define _XSP %rsp /* x86_64 stack pointer */
|
||||||
|
# define _XAX %rax /* scratch */
|
||||||
|
# define _XBX %rbx /* scratch2 */
|
||||||
|
// full-length Apple ][ registers
|
||||||
|
# define XY_Reg_X %rbx /* 6502 X&Y flags */
|
||||||
|
# define AF_Reg_X %rcx /* 6502 F&A flags */
|
||||||
|
# define SP_Reg_X %rdx /* 6502 Stack pointer */
|
||||||
|
# define PC_Reg_X %rsi /* 6502 Program Counter */
|
||||||
|
# define EffectiveAddr_X %rdi /* Effective address */
|
||||||
|
// full-length assembly instructions
|
||||||
|
# define addLQ addq
|
||||||
|
# define andLQ andq
|
||||||
|
# define decLQ decq
|
||||||
|
# define orLQ orq
|
||||||
|
# define movLQ movq
|
||||||
|
# define movzbLQ movzbq
|
||||||
|
# define movzwLQ movzwq
|
||||||
|
# define popaLQ popaq
|
||||||
|
# define popLQ popq
|
||||||
|
# define pushaLQ pushaq
|
||||||
|
# define pushfLQ pushfq
|
||||||
|
# define pushLQ pushq
|
||||||
|
# define rorLQ rorq
|
||||||
|
# define shlLQ shlq
|
||||||
|
# define shrLQ shrq
|
||||||
|
# define subLQ subq
|
||||||
|
# define testLQ testq
|
||||||
|
# define xorLQ xorq
|
||||||
#else
|
#else
|
||||||
# define SZ_PTR 4
|
# define SZ_PTR 4
|
||||||
|
# define _XBP %ebp /* x86 base pointer */
|
||||||
# define _XSP %esp /* x86 stack pointer */
|
# define _XSP %esp /* x86 stack pointer */
|
||||||
# define _XAX %eax /* scratch */
|
# define _XAX %eax /* scratch */
|
||||||
# define _XBX %ebx /* scratch2 */
|
# define _XBX %ebx /* scratch2 */
|
||||||
|
|
|
@ -310,14 +310,6 @@
|
||||||
#define DebugBCDCheck
|
#define DebugBCDCheck
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DoADC_d GetFromEA_B \
|
|
||||||
DebugBCDCheck \
|
|
||||||
bt $C_Flag_Bit, AF_Reg_X; \
|
|
||||||
adcb A_Reg, %al; \
|
|
||||||
daa; \
|
|
||||||
movb %al, A_Reg; \
|
|
||||||
FlagNVZC
|
|
||||||
|
|
||||||
#define DoAND GetFromEA_B \
|
#define DoAND GetFromEA_B \
|
||||||
andb %al, A_Reg; \
|
andb %al, A_Reg; \
|
||||||
FlagNZ
|
FlagNZ
|
||||||
|
@ -411,17 +403,6 @@
|
||||||
adcb %al, A_Reg; \
|
adcb %al, A_Reg; \
|
||||||
FlagNVZC
|
FlagNVZC
|
||||||
|
|
||||||
#define DoSBC_d GetFromEA_B \
|
|
||||||
DebugBCDCheck \
|
|
||||||
bt $C_Flag_Bit, AF_Reg_X; \
|
|
||||||
cmc; \
|
|
||||||
xchgb A_Reg, %al; \
|
|
||||||
sbbb A_Reg, %al; \
|
|
||||||
das; \
|
|
||||||
movb %al, A_Reg; \
|
|
||||||
cmc; \
|
|
||||||
FlagNVZC
|
|
||||||
|
|
||||||
#define DoSTA movb A_Reg, %al; \
|
#define DoSTA movb A_Reg, %al; \
|
||||||
PutToEA_B
|
PutToEA_B
|
||||||
|
|
||||||
|
@ -460,7 +441,17 @@
|
||||||
// Decimal mode
|
// Decimal mode
|
||||||
E(op_ADC_dec)
|
E(op_ADC_dec)
|
||||||
incb DebugCycleCount // +1 cycle
|
incb DebugCycleCount // +1 cycle
|
||||||
DoADC_d
|
GetFromEA_B
|
||||||
|
DebugBCDCheck
|
||||||
|
bt $C_Flag_Bit, AF_Reg_X
|
||||||
|
adcb A_Reg, %al
|
||||||
|
#ifdef __LP64__
|
||||||
|
#warning TODO FIXME das instruction
|
||||||
|
#else
|
||||||
|
daa
|
||||||
|
#endif
|
||||||
|
movb %al, A_Reg
|
||||||
|
FlagNVZC
|
||||||
Continue
|
Continue
|
||||||
|
|
||||||
E(op_ADC_imm) // 0x69
|
E(op_ADC_imm) // 0x69
|
||||||
|
@ -818,7 +809,8 @@ E(op_BRK)
|
||||||
Push(%ah)
|
Push(%ah)
|
||||||
Push(%al)
|
Push(%al)
|
||||||
orb $(B_Flag|X_Flag), F_Reg
|
orb $(B_Flag|X_Flag), F_Reg
|
||||||
movzbLQ F_Reg, _XAX
|
xorw %ax, %ax
|
||||||
|
movb F_Reg, %al
|
||||||
movb SN(cpu65_flags_encode)(,_XAX,1), %al
|
movb SN(cpu65_flags_encode)(,_XAX,1), %al
|
||||||
Push(%al)
|
Push(%al)
|
||||||
orb $I_Flag, F_Reg
|
orb $I_Flag, F_Reg
|
||||||
|
@ -1568,7 +1560,20 @@ E(op_RTS) // 0x60
|
||||||
|
|
||||||
E(op_SBC_dec)
|
E(op_SBC_dec)
|
||||||
incb DebugCycleCount // +1 cycle
|
incb DebugCycleCount // +1 cycle
|
||||||
DoSBC_d
|
GetFromEA_B
|
||||||
|
DebugBCDCheck
|
||||||
|
bt $C_Flag_Bit, AF_Reg_X
|
||||||
|
cmc
|
||||||
|
xchgb A_Reg, %al
|
||||||
|
sbbb A_Reg, %al
|
||||||
|
#ifdef __LP64__
|
||||||
|
#warning TODO FIXME das instruction
|
||||||
|
#else
|
||||||
|
das
|
||||||
|
#endif
|
||||||
|
movb %al, A_Reg
|
||||||
|
cmc
|
||||||
|
FlagNVZC
|
||||||
Continue
|
Continue
|
||||||
|
|
||||||
E(op_SBC_imm) // 0xe9
|
E(op_SBC_imm) // 0xe9
|
||||||
|
@ -2001,7 +2006,8 @@ ex_irq: testb $I_Flag, F_Reg // Already interrupt
|
||||||
Push(%ah)
|
Push(%ah)
|
||||||
Push(%al)
|
Push(%al)
|
||||||
orb $X_Flag, F_Reg
|
orb $X_Flag, F_Reg
|
||||||
movzbLQ F_Reg, _XAX
|
xorw %ax, %ax
|
||||||
|
movb F_Reg, %al
|
||||||
movb SN(cpu65_flags_encode)(,_XAX,1), %al
|
movb SN(cpu65_flags_encode)(,_XAX,1), %al
|
||||||
Push(%al)
|
Push(%al)
|
||||||
orb $(B_Flag | I_Flag), F_Reg
|
orb $(B_Flag | I_Flag), F_Reg
|
||||||
|
@ -2016,7 +2022,8 @@ ex_irq: testb $I_Flag, F_Reg // Already interrupt
|
||||||
CPU thread main entry and exit points
|
CPU thread main entry and exit points
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
E(cpu65_run)
|
E(cpu65_run)
|
||||||
pushaLQ // ENTER CPURUN
|
pushLQ _XBP
|
||||||
|
movLQ _XSP, _XBP
|
||||||
cmpb $0, SN(emul_reinitialize)
|
cmpb $0, SN(emul_reinitialize)
|
||||||
jnz 1f
|
jnz 1f
|
||||||
|
|
||||||
|
@ -2053,18 +2060,19 @@ exit_cpu65_run:
|
||||||
movw EffectiveAddr, DebugCurrEA
|
movw EffectiveAddr, DebugCurrEA
|
||||||
movw PC_Reg, SN(cpu65_current)
|
movw PC_Reg, SN(cpu65_current)
|
||||||
movb A_Reg, SN(cpu65_current)+2
|
movb A_Reg, SN(cpu65_current)+2
|
||||||
movzbLQ F_Reg, _XAX
|
xorw %ax, %ax
|
||||||
|
movb F_Reg, %al
|
||||||
movb SN(cpu65_flags_encode)(,_XAX,1), %al
|
movb SN(cpu65_flags_encode)(,_XAX,1), %al
|
||||||
movb %al, SN(cpu65_current)+3
|
movb %al, SN(cpu65_current)+3
|
||||||
movb X_Reg, SN(cpu65_current)+4
|
movb X_Reg, SN(cpu65_current)+4
|
||||||
movb Y_Reg, SN(cpu65_current)+5
|
movb Y_Reg, SN(cpu65_current)+5
|
||||||
movb SP_Reg_L, SN(cpu65_current)+6
|
movb SP_Reg_L, SN(cpu65_current)+6
|
||||||
popaLQ
|
popLQ _XBP
|
||||||
ret
|
ret
|
||||||
|
|
||||||
emul_reinit: movb $0, SN(cpu65__signal)
|
emul_reinit: movb $0, SN(cpu65__signal)
|
||||||
movb $1, SN(emul_reinitialize)
|
movb $1, SN(emul_reinitialize)
|
||||||
popaLQ
|
popLQ _XBP
|
||||||
ret
|
ret
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------
|
/* -------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user