Fix calling conventions on x86_64

This commit is contained in:
Aaron Culliney 2014-06-08 13:12:48 -07:00
parent 45f29f363f
commit f72976a566
2 changed files with 26 additions and 10 deletions

View File

@ -2021,7 +2021,12 @@ ex_irq: testb $I_Flag, F_Reg // Already interrupt
/* -------------------------------------------------------------------------
CPU thread main entry and exit points
------------------------------------------------------------------------- */
E(cpu65_run)
#ifdef __LP64__
pushq %rbx
// NOTE: should we be also preserving r12-r15?
#endif
pushLQ _XBP
movLQ _XSP, _XBP
cmpb $0, SN(emul_reinitialize)
@ -2067,12 +2072,15 @@ exit_cpu65_run:
movb X_Reg, SN(cpu65_current)+4
movb Y_Reg, SN(cpu65_current)+5
movb SP_Reg_L, SN(cpu65_current)+6
popLQ _XBP
ret
jmp exit_frame
emul_reinit: movb $0, SN(cpu65__signal)
movb $1, SN(emul_reinitialize)
popLQ _XBP
exit_frame: popLQ _XBP
#ifdef __LP64__
popq %rbx
#endif
ret
/* -------------------------------------------------------------------------

View File

@ -57,7 +57,17 @@ E(func) addLQ SN(pointer),EffectiveAddr_X; \
1: ret;
// TODO FIXME : implement CDECL prologue/epilogues...
#ifdef __LP64__
# define _PUSH_ARGS pushLQ EffectiveAddr_X; /* preserve */ \
movLQ _XAX, %rsi; /* %rdi = ea, %rsi = byte */
# define _POP_ARGS popLQ EffectiveAddr_X; /* restore */
#else
# define _PUSH_ARGS pushLQ _XAX; /* byte is arg2 */ \
pushLQ EffectiveAddr_X; /* ea is arg1 (and preserved) */
# define _POP_ARGS popLQ EffectiveAddr_X; /* restore ea */ \
popLQ _XAX;
#endif
#define GLUE_C_WRITE(func) \
E(func) pushLQ _XAX; \
pushLQ XY_Reg_X; \
@ -65,11 +75,9 @@ E(func) pushLQ _XAX; \
pushLQ SP_Reg_X; \
pushLQ PC_Reg_X; \
andLQ $0xff,_XAX; \
pushLQ _XAX; \
pushLQ EffectiveAddr_X; \
_PUSH_ARGS \
call SN(c_##func); \
popLQ EffectiveAddr_X; /* dummy */ \
popLQ _XAX; /* dummy */ \
_POP_ARGS \
popLQ PC_Reg_X; \
popLQ SP_Reg_X; \
popLQ AF_Reg_X; \
@ -84,9 +92,9 @@ E(func) pushLQ XY_Reg_X; \
pushLQ SP_Reg_X; \
pushLQ PC_Reg_X; \
pushLQ _XAX; /* HACK: works around mysterious issue with generated mov(_XAX), _XAX ... */ \
pushLQ EffectiveAddr_X; \
pushLQ EffectiveAddr_X; /* ea is arg0 (and preserved) */ \
call SN(c_##func); \
popLQ EffectiveAddr_X; /* dummy */ \
popLQ EffectiveAddr_X; /* restore ea */ \
movb %al, %dl; \
popLQ _XAX; /* ... ugh */ \
movb %dl, %al; \