Use name-indirection for all registers

This commit is contained in:
Aaron Culliney 2014-06-07 13:44:14 -07:00
parent 30cf264aa6
commit 23e6e0ea75
3 changed files with 18 additions and 21 deletions

View File

@ -32,7 +32,9 @@
# error not ready # error not ready
#else #else
# define SZ_PTR 4 # define SZ_PTR 4
# define _XSP %esp /* x86 stack pointer */
# define _XAX %eax /* scratch */ # define _XAX %eax /* scratch */
# define _XBX %ebx /* scratch2 */
# define XY_Reg_X %ebx /* 6502 X&Y flags */ # define XY_Reg_X %ebx /* 6502 X&Y flags */
# define AF_Reg_X %ecx /* 6502 F&A flags */ # define AF_Reg_X %ecx /* 6502 F&A flags */
# define SP_Reg_X %edx /* 6502 Stack pointer */ # define SP_Reg_X %edx /* 6502 Stack pointer */

View File

@ -82,7 +82,7 @@
#define BranchXCycles \ #define BranchXCycles \
incb DebugCycleCount; /* +1 branch taken */ \ incb DebugCycleCount; /* +1 branch taken */ \
shll $16, %ebx; \ shll $16, _XBX; \
movw PC_Reg, %bx; \ movw PC_Reg, %bx; \
cbw; \ cbw; \
addw %bx, %ax; \ addw %bx, %ax; \
@ -90,7 +90,7 @@
cmpb %ah, %bh; \ cmpb %ah, %bh; \
je 9f; \ je 9f; \
incb DebugCycleCount; /* +1 branch new page */ \ incb DebugCycleCount; /* +1 branch new page */ \
9: shrl $16, %ebx; 9: shrl $16, _XBX;
#define FlagC lahf; \ #define FlagC lahf; \
andb $C_Flag, %ah; \ andb $C_Flag, %ah; \
@ -2047,20 +2047,16 @@ E(cpu65_run)
jmp continue1 jmp continue1
1: movb $0, SN(emul_reinitialize) 1: movb $0, SN(emul_reinitialize)
/* Zero all registers, as well as the unused 32-bit parts // Zero all used registers
* of variables. (which may need to be kept 0)
*
* Note: dependent on assignment of registers
*/
xorl _XAX, _XAX xorl _XAX, _XAX
xorl %ebx, %ebx xorl XY_Reg_X, XY_Reg_X
xorl %ecx, %ecx xorl AF_Reg_X, AF_Reg_X
xorl %esi, %esi xorl PC_Reg_X, PC_Reg_X
xorl %edi, %edi xorl EffectiveAddr_X, EffectiveAddr_X
movl $0x1FF, SP_Reg_X movl $0x1FF, SP_Reg_X
jmp ex_reset jmp ex_reset
exit_cpu65_run: // Return to timing loop ... exit_cpu65_run:
// Save CPU state when returning from being called from C // Save CPU state when returning from being called from C
xorl _XAX, _XAX xorl _XAX, _XAX
movw EffectiveAddr, DebugCurrEA movw EffectiveAddr, DebugCurrEA
@ -2075,7 +2071,7 @@ exit_cpu65_run: // Return to timing
popal popal
ret ret
emul_reinit: movb $0, SN(cpu65__signal) // Return to timing loop ... emul_reinit: movb $0, SN(cpu65__signal)
movb $1, SN(emul_reinitialize) movb $1, SN(emul_reinitialize)
popal popal
ret ret
@ -2085,11 +2081,10 @@ emul_reinit: movb $0, SN(cpu65__signal) // Return to timing
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
E(cpu65_direct_write) E(cpu65_direct_write)
/* NB: dependent on register choices */ pushl EffectiveAddr_X
pushl %edi movl 8(_XSP),EffectiveAddr_X
movl 8(%esp),%edi movl 12(_XSP),_XAX
movl 12(%esp),_XAX
call *SN(cpu65_vmem)+4(,EffectiveAddr_X,SZ_PTR*2) call *SN(cpu65_vmem)+4(,EffectiveAddr_X,SZ_PTR*2)
popl %edi popl EffectiveAddr_X
ret ret

View File

@ -68,8 +68,8 @@ E(func) pushl _XAX; \
pushl _XAX; \ pushl _XAX; \
pushl EffectiveAddr_X; \ pushl EffectiveAddr_X; \
call SN(c_##func); \ call SN(c_##func); \
popl %edx; /* dummy */ \ popl EffectiveAddr_X; /* dummy */ \
popl %edx; /* dummy */ \ popl _XAX; /* dummy */ \
popl PC_Reg_X; \ popl PC_Reg_X; \
popl SP_Reg_X; \ popl SP_Reg_X; \
popl AF_Reg_X; \ popl AF_Reg_X; \
@ -86,7 +86,7 @@ E(func) pushl XY_Reg_X; \
pushl _XAX; /* HACK: works around mysterious issue with generated mov(_XAX), _XAX ... */ \ pushl _XAX; /* HACK: works around mysterious issue with generated mov(_XAX), _XAX ... */ \
pushl EffectiveAddr_X; \ pushl EffectiveAddr_X; \
call SN(c_##func); \ call SN(c_##func); \
popl %edx; /* dummy */ \ popl EffectiveAddr_X; /* dummy */ \
movb %al, %dl; \ movb %al, %dl; \
popl _XAX; /* ... ugh */ \ popl _XAX; /* ... ugh */ \
movb %dl, %al; \ movb %dl, %al; \