2013-06-11 07:08:15 +00:00
|
|
|
/*
|
|
|
|
* Apple // emulator for Linux: Glue file prologue for Intel 386
|
|
|
|
*
|
|
|
|
* Copyright 1994 Alexander Jean-Claude Bottema
|
|
|
|
* Copyright 1995 Stephen Lee
|
|
|
|
* Copyright 1997, 1998 Aaron Culliney
|
|
|
|
* Copyright 1998, 1999, 2000 Michael Deutschmann
|
|
|
|
*
|
|
|
|
* This software package is subject to the GNU General Public License
|
|
|
|
* version 2 or later (your choice) as published by the Free Software
|
|
|
|
* Foundation.
|
|
|
|
*
|
|
|
|
* THERE ARE NO WARRANTIES WHATSOEVER.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define __ASSEMBLY__
|
2013-11-23 07:40:24 +00:00
|
|
|
#include "apple2.h"
|
|
|
|
#include "misc.h"
|
2014-05-10 23:39:51 +00:00
|
|
|
#include "cpu.h"
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2014-05-10 23:31:07 +00:00
|
|
|
#define GLUE_FIXED_READ(func,address) \
|
|
|
|
E(func) movb SN(address)(%edi),%al; \
|
|
|
|
ret;
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2014-05-10 23:31:07 +00:00
|
|
|
#define GLUE_FIXED_WRITE(func,address) \
|
|
|
|
E(func) movb %al,SN(address)(%edi); \
|
|
|
|
ret;
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-11-23 07:40:24 +00:00
|
|
|
#define GLUE_BANK_MAYBEREAD(func,pointer) \
|
|
|
|
E(func) testl $SS_CXROM, SN(softswitches); \
|
|
|
|
jnz 1f; \
|
|
|
|
call *SN(pointer); \
|
|
|
|
ret; \
|
|
|
|
1: addl SN(pointer),%edi; \
|
|
|
|
movb (%edi),%al; \
|
|
|
|
subl SN(pointer),%edi; \
|
|
|
|
ret;
|
|
|
|
|
2013-06-11 07:08:15 +00:00
|
|
|
#define GLUE_BANK_READ(func,pointer) \
|
2014-05-10 23:31:07 +00:00
|
|
|
E(func) addl SN(pointer),%edi; \
|
|
|
|
movb (%edi),%al; \
|
|
|
|
subl SN(pointer),%edi; \
|
|
|
|
ret;
|
2013-06-11 07:08:15 +00:00
|
|
|
|
|
|
|
#define GLUE_BANK_WRITE(func,pointer) \
|
2014-05-10 23:31:07 +00:00
|
|
|
E(func) addl SN(pointer),%edi; \
|
|
|
|
movb %al,(%edi); \
|
|
|
|
subl SN(pointer),%edi; \
|
|
|
|
ret;
|
2013-06-11 07:08:15 +00:00
|
|
|
|
|
|
|
#define GLUE_BANK_MAYBEWRITE(func,pointer) \
|
2014-05-10 23:31:07 +00:00
|
|
|
E(func) addl SN(pointer),%edi; \
|
|
|
|
cmpl $0,SN(pointer); \
|
|
|
|
jz 1f; \
|
|
|
|
movb %al,(%edi); \
|
|
|
|
1: ret;
|
2013-06-11 07:08:15 +00:00
|
|
|
|
|
|
|
|
2013-11-06 06:11:27 +00:00
|
|
|
// TODO FIXME : implement CDECL prologue/epilogues...
|
2013-06-11 07:08:15 +00:00
|
|
|
#define GLUE_C_WRITE(func) \
|
2014-05-10 23:31:07 +00:00
|
|
|
E(func) pushl %eax; \
|
2014-05-10 23:45:10 +00:00
|
|
|
pushl XY_Regs_32; \
|
2014-05-10 23:39:51 +00:00
|
|
|
pushl FF_Reg; \
|
|
|
|
pushl SP_Reg; \
|
2014-05-10 23:45:10 +00:00
|
|
|
pushl PC_Reg_E; \
|
2014-05-10 23:31:07 +00:00
|
|
|
andl $0xff,%eax; \
|
|
|
|
pushl %eax; \
|
2014-05-10 23:39:51 +00:00
|
|
|
pushl EffectiveAddr_E; \
|
2014-05-10 23:31:07 +00:00
|
|
|
call SN(c_##func); \
|
|
|
|
popl %edx; /* dummy */ \
|
|
|
|
popl %edx; /* dummy */ \
|
2014-05-10 23:45:10 +00:00
|
|
|
popl PC_Reg_E; \
|
2014-05-10 23:39:51 +00:00
|
|
|
popl SP_Reg; \
|
|
|
|
popl FF_Reg; \
|
2014-05-10 23:45:10 +00:00
|
|
|
popl XY_Regs_32; \
|
2014-05-10 23:31:07 +00:00
|
|
|
popl %eax; \
|
|
|
|
ret;
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-11-06 06:11:27 +00:00
|
|
|
// TODO FIXME : implement CDECL prologue/epilogues...
|
2014-05-11 04:25:54 +00:00
|
|
|
#define _GLUE_C_READ(func, ...) \
|
2014-05-10 23:45:10 +00:00
|
|
|
E(func) pushl XY_Regs_32; \
|
2014-05-10 23:39:51 +00:00
|
|
|
pushl FF_Reg; \
|
|
|
|
pushl SP_Reg; \
|
2014-05-10 23:45:10 +00:00
|
|
|
pushl PC_Reg_E; \
|
2014-05-10 23:39:51 +00:00
|
|
|
pushl EffectiveAddr_E; \
|
2014-05-10 23:31:07 +00:00
|
|
|
call SN(c_##func); \
|
|
|
|
popl %edx; /* dummy */ \
|
2014-05-10 23:45:10 +00:00
|
|
|
popl PC_Reg_E; \
|
2014-05-10 23:39:51 +00:00
|
|
|
popl SP_Reg; \
|
|
|
|
popl FF_Reg; \
|
2014-05-10 23:45:10 +00:00
|
|
|
popl XY_Regs_32; \
|
2014-05-11 04:25:54 +00:00
|
|
|
__VA_ARGS__ \
|
2014-05-10 23:31:07 +00:00
|
|
|
ret;
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2014-05-11 04:25:54 +00:00
|
|
|
// TODO FIXME : implement CDECL prologue/epilogues...
|
|
|
|
#define GLUE_C_READ(FUNC) _GLUE_C_READ(FUNC)
|
|
|
|
|
|
|
|
#define GLUE_C_READ_ALTZP(FUNC) _GLUE_C_READ(FUNC, \
|
|
|
|
pushl %eax; \
|
|
|
|
andl $0xFFFF, SP_Reg; \
|
|
|
|
movl SN(base_stackzp), %eax; \
|
|
|
|
subl $SN(apple_ii_64k), %eax; \
|
|
|
|
orl %eax, SP_Reg; \
|
|
|
|
popl %eax; \
|
|
|
|
)
|
|
|
|
|