2013-06-11 00:08:15 -07: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-22 23:40:24 -08:00
|
|
|
#include "apple2.h"
|
|
|
|
#include "misc.h"
|
2013-06-11 00:08:15 -07:00
|
|
|
|
|
|
|
#define GLUE_FIXED_READ(func,address) \
|
|
|
|
E(func) movb SN(address)(%edi),%al; \
|
|
|
|
ret;
|
|
|
|
|
|
|
|
#define GLUE_FIXED_WRITE(func,address) \
|
|
|
|
E(func) movb %al,SN(address)(%edi); \
|
|
|
|
ret;
|
|
|
|
|
2013-11-22 23:40:24 -08: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 00:08:15 -07:00
|
|
|
#define GLUE_BANK_READ(func,pointer) \
|
|
|
|
E(func) addl SN(pointer),%edi; \
|
|
|
|
movb (%edi),%al; \
|
|
|
|
subl SN(pointer),%edi; \
|
|
|
|
ret;
|
|
|
|
|
|
|
|
#define GLUE_BANK_WRITE(func,pointer) \
|
|
|
|
E(func) addl SN(pointer),%edi; \
|
|
|
|
movb %al,(%edi); \
|
|
|
|
subl SN(pointer),%edi; \
|
|
|
|
ret;
|
|
|
|
|
|
|
|
#define GLUE_BANK_MAYBEWRITE(func,pointer) \
|
|
|
|
E(func) addl SN(pointer),%edi; \
|
|
|
|
cmpl $0,SN(pointer); \
|
|
|
|
jz 1f; \
|
|
|
|
movb %al,(%edi); \
|
|
|
|
1: ret;
|
|
|
|
|
|
|
|
|
2013-11-05 22:11:27 -08:00
|
|
|
// TODO FIXME : implement CDECL prologue/epilogues...
|
2013-06-11 00:08:15 -07:00
|
|
|
#define GLUE_C_WRITE(func) \
|
|
|
|
E(func) pushl %eax; \
|
|
|
|
pushl %ecx; \
|
|
|
|
pushl %edx; \
|
2013-11-05 22:11:27 -08:00
|
|
|
andl $0xff,%eax; \
|
2013-06-11 00:08:15 -07:00
|
|
|
pushl %eax; \
|
|
|
|
pushl %edi; \
|
2013-11-05 22:11:27 -08:00
|
|
|
call SN(c_##func); \
|
2013-06-11 00:08:15 -07:00
|
|
|
popl %edx; /* dummy */ \
|
|
|
|
popl %edx; /* dummy */ \
|
|
|
|
popl %edx; \
|
|
|
|
popl %ecx; \
|
|
|
|
popl %eax; \
|
|
|
|
ret; \
|
|
|
|
|
2013-11-05 22:11:27 -08:00
|
|
|
// TODO FIXME : implement CDECL prologue/epilogues...
|
2013-06-11 00:08:15 -07:00
|
|
|
#define GLUE_C_READ(func) \
|
2013-11-05 22:11:27 -08:00
|
|
|
E(func) /*pushl %eax;*/ \
|
2013-06-11 00:08:15 -07:00
|
|
|
pushl %ecx; \
|
|
|
|
pushl %edx; \
|
|
|
|
pushl %edi; \
|
2013-11-05 22:11:27 -08:00
|
|
|
call SN(c_##func); \
|
|
|
|
/*movb %al,12(%esp);*/ \
|
2013-06-11 00:08:15 -07:00
|
|
|
popl %edx; /* dummy */ \
|
|
|
|
popl %edx; \
|
|
|
|
popl %ecx; \
|
2013-11-05 22:11:27 -08:00
|
|
|
/*popl %eax;*/ \
|
2013-06-11 00:08:15 -07:00
|
|
|
ret;
|
|
|
|
|