Refactoring assembly : move x86 registers to separate file

This commit is contained in:
Aaron Culliney 2014-06-07 10:54:56 -07:00
parent 6d63592ada
commit 24ed2ea6ef
5 changed files with 35 additions and 22 deletions

View File

@ -17,7 +17,7 @@
#ifndef __CPU_H_
#define __CPU_H_
#ifndef __ASSEMBLER__
#if !defined(__ASSEMBLER__)
#include <sys/types.h>
#include <stdint.h>
@ -116,18 +116,4 @@ extern int16_t cpu65_cycles_to_execute;
#define V_Flag_6502 0x40 // o[V]erflow
#define N_Flag_6502 0x80 // [N]egative
#define X_Reg %bl /* 6502 X register in %bl */
#define Y_Reg %bh /* 6502 Y register in %bh */
#define XY_Regs_32 %ebx /* 6502 X&Y flags */
#define A_Reg %cl /* 6502 A register in %cl */
#define F_Reg %ch /* 6502 flags in %ch */
#define FF_Reg %ecx /* 6502 F&A flags */
#define SP_Reg_L %dl /* 6502 Stack pointer low */
#define SP_Reg_H %dh /* 6502 Stack pointer high */
#define SP_Reg %edx /* 6502 Stack pointer */
#define PC_Reg %si /* 6502 Program Counter */
#define PC_Reg_E %esi /* 6502 Program Counter */
#define EffectiveAddr %di /* Effective address */
#define EffectiveAddr_E %edi /* Effective address */
#endif // whole file

27
src/x86/cpu-regs.h Normal file
View File

@ -0,0 +1,27 @@
/*
* Apple // emulator for *nix
*
* 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.
*
*/
#include "cpu.h"
#define X_Reg %bl /* 6502 X register in %bl */
#define Y_Reg %bh /* 6502 Y register in %bh */
#define XY_Regs %ebx /* 6502 X&Y flags */
#define A_Reg %cl /* 6502 A register in %cl */
#define F_Reg %ch /* 6502 flags in %ch */
#define FF_Reg %ecx /* 6502 F&A flags */
#define SP_Reg_L %dl /* 6502 Stack pointer low */
#define SP_Reg_H %dh /* 6502 Stack pointer high */
#define SP_Reg %edx /* 6502 Stack pointer */
#define PC_Reg %si /* 6502 Program Counter */
#define PC_Reg_E %esi /* 6502 Program Counter */
#define EffectiveAddr %di /* Effective address */
#define EffectiveAddr_E %edi /* Effective address */

View File

@ -15,7 +15,7 @@
*/
#include "apple2.h"
#include "cpu.h"
#include "cpu-regs.h"
#include "misc.h"
#define DebugCurrEA SN(cpu65_debug)

View File

@ -1,4 +1,4 @@
#! /bin/sh
#!/bin/sh
echo '/* Automatically Generated -- do not edit */'
echo '#include "x86/glue-prologue.h"'
grep -E -h '^(GLUE_)|(#if)|(#endif)|(#else)|(#elif)' $*

View File

@ -17,7 +17,7 @@
#define __ASSEMBLY__
#include "apple2.h"
#include "misc.h"
#include "cpu.h"
#include "cpu-regs.h"
#define GLUE_FIXED_READ(func,address) \
E(func) movb SN(address)(EffectiveAddr_E),%al; \
@ -60,7 +60,7 @@ E(func) addl SN(pointer),EffectiveAddr_E; \
// TODO FIXME : implement CDECL prologue/epilogues...
#define GLUE_C_WRITE(func) \
E(func) pushl %eax; \
pushl XY_Regs_32; \
pushl XY_Regs; \
pushl FF_Reg; \
pushl SP_Reg; \
pushl PC_Reg_E; \
@ -73,13 +73,13 @@ E(func) pushl %eax; \
popl PC_Reg_E; \
popl SP_Reg; \
popl FF_Reg; \
popl XY_Regs_32; \
popl XY_Regs; \
popl %eax; \
ret;
// TODO FIXME : implement CDECL prologue/epilogues...
#define _GLUE_C_READ(func, ...) \
E(func) pushl XY_Regs_32; \
E(func) pushl XY_Regs; \
pushl FF_Reg; \
pushl SP_Reg; \
pushl PC_Reg_E; \
@ -93,7 +93,7 @@ E(func) pushl XY_Regs_32; \
popl PC_Reg_E; \
popl SP_Reg; \
popl FF_Reg; \
popl XY_Regs_32; \
popl XY_Regs; \
__VA_ARGS__ \
ret;