REFACTOR : whitespace, style, remove deadcode, extract code into macro

This commit is contained in:
Aaron Culliney 2015-02-14 21:30:06 -08:00
parent 9a87aa8a3d
commit 12ba31f1af
2 changed files with 38 additions and 58 deletions

View File

@ -91,15 +91,17 @@ void cpu65_trace_checkpoint(void);
# define C_Flag (C_Flag_Bit>>3) /* 6502 Carry */ # define C_Flag (C_Flag_Bit>>3) /* 6502 Carry */
# define X_Flag 0x2 /* 6502 Xtra */ # define X_Flag 0x2 /* 6502 Xtra */
# define I_Flag 0x4 /* 6502 Interrupt disable */ # define I_Flag 0x4 /* 6502 Interrupt disable */
# define V_Flag 0x8 /* 6502 Overflow */ # define V_Flag 0x8 /* 6502 oVerflow */
# define B_Flag 0x10 /* 6502 Break */ # define B_Flag 0x10 /* 6502 Break */
# define D_Flag 0x20 /* 6502 Decimal mode */ # define D_Flag 0x20 /* 6502 Decimal mode */
# define Z_Flag 0x40 /* 6502 Zero */ # define Z_Flag 0x40 /* 6502 Zero */
# define N_Flag 0x80 /* 6502 Neg */ # define N_Flag 0x80 /* 6502 Negative */
#elif defined(__arm__) #elif defined(__arm__)
# error in progress ... # error in progress ...
#elif defined(__aarch64__) #elif defined(__aarch64__)
# error soon ... # error soon ...
#else
# error unknown machine architecture
#endif #endif
/* /*

View File

@ -263,17 +263,6 @@
_GetAbs_Y \ _GetAbs_Y \
9: movLQ _XAX, EffectiveAddr_X; 9: movLQ _XAX, EffectiveAddr_X;
/* Absolute Indirect Addressing - The second and third bytes of the
instruction are the low and high bytes of an address, respectively.
The contents of the fully specified memory location is the
low-order byte of the effective address. The next memory location
contains the high order byte of the effective address. */
/* (unused at the moment. It applies to JMP, but JMP's addressing is done
* without the macro)
*/
#define GetInd GetFromPC_W; \
GetFromMem_W(_XAX)
/* Zero Page Indirect Addressing (65c02) - The second byte of the /* Zero Page Indirect Addressing (65c02) - The second byte of the
instruction points to a memory location on page zero containing the instruction points to a memory location on page zero containing the
low order byte of the effective address. The next location on page low order byte of the effective address. The next location on page
@ -377,7 +366,7 @@
#define DoASL GetFromEA_B \ #define DoASL GetFromEA_B \
addb %al, %al; \ addb %al, %al; \
FlagNZC \ FlagNZC \
PutToEA_B \ PutToEA_B
/* SAR (and the following AND) effectively moves /* SAR (and the following AND) effectively moves
* bit 6 to Bit 3 while leaving Bit 7 unchanged */ * bit 6 to Bit 3 while leaving Bit 7 unchanged */
@ -421,17 +410,17 @@
#define DoLDA GetFromEA_B \ #define DoLDA GetFromEA_B \
movb %al, A_Reg; \ movb %al, A_Reg; \
orb %al, %al; \ orb A_Reg, A_Reg; \
FlagNZ FlagNZ
#define DoLDX GetFromEA_B \ #define DoLDX GetFromEA_B \
movb %al, X_Reg; \ movb %al, X_Reg; \
orb %al, %al; \ orb X_Reg, X_Reg; \
FlagNZ FlagNZ
#define DoLDY GetFromEA_B \ #define DoLDY GetFromEA_B \
movb %al, Y_Reg; \ movb %al, Y_Reg; \
orb %al, %al; \ orb Y_Reg, Y_Reg; \
FlagNZ FlagNZ
#define DoLSR GetFromEA_B \ #define DoLSR GetFromEA_B \
@ -445,7 +434,7 @@
#define DoROL GetFromEA_B \ #define DoROL GetFromEA_B \
bt $C_Flag_Bit, AF_Reg_X; \ bt $C_Flag_Bit, AF_Reg_X; \
adcb %al,%al; \ adcb %al, %al; \
FlagNZC \ FlagNZC \
PutToEA_B PutToEA_B
@ -551,24 +540,25 @@ _daa_finish: popq _XBX
#endif #endif
Continue Continue
#define maybe_DoADC_d \
testb $D_Flag, F_Reg; /* Decimal mode? */ \
jnz CALL(op_ADC_dec) /* Yes, jump to decimal version */
ENTRY(op_ADC_imm) // 0x69 ENTRY(op_ADC_imm) // 0x69
GetImm GetImm
testb $D_Flag, F_Reg // Decimal mode? maybe_DoADC_d
jnz CALL(op_ADC_dec) // Yes, jump to decimal version
DoADC_b DoADC_b
Continue Continue
ENTRY(op_ADC_zpage) // 0x65 ENTRY(op_ADC_zpage) // 0x65
GetZPage GetZPage
testb $D_Flag, F_Reg // Decimal mode? maybe_DoADC_d
jnz CALL(op_ADC_dec) // Yes, jump to decimal version
DoADC_b DoADC_b
Continue Continue
ENTRY(op_ADC_zpage_x) // 0x75 ENTRY(op_ADC_zpage_x) // 0x75
GetZPage_X GetZPage_X
testb $D_Flag, F_Reg // Decimal mode? maybe_DoADC_d
jnz CALL(op_ADC_dec) // Yes, jump to decimal version
DoADC_b DoADC_b
Continue Continue
@ -578,44 +568,38 @@ ENTRY(op_ADC_zpage_y)
ENTRY(op_ADC_abs) // 0x6d ENTRY(op_ADC_abs) // 0x6d
GetAbs GetAbs
testb $D_Flag, F_Reg // Decimal mode? maybe_DoADC_d
jnz CALL(op_ADC_dec) // Yes, jump to decimal version
DoADC_b DoADC_b
Continue Continue
ENTRY(op_ADC_abs_x) // 0x7d ENTRY(op_ADC_abs_x) // 0x7d
GetAbs_X GetAbs_X
testb $D_Flag, F_Reg // Decimal mode? maybe_DoADC_d
jnz CALL(op_ADC_dec) // Yes, jump to decimal version
DoADC_b DoADC_b
Continue Continue
ENTRY(op_ADC_abs_y) // 0x79 ENTRY(op_ADC_abs_y) // 0x79
GetAbs_Y GetAbs_Y
testb $D_Flag, F_Reg // Decimal mode? maybe_DoADC_d
jnz CALL(op_ADC_dec) // Yes, jump to decimal version
DoADC_b DoADC_b
Continue Continue
ENTRY(op_ADC_ind_x) // 0x61 ENTRY(op_ADC_ind_x) // 0x61
GetIndZPage_X GetIndZPage_X
testb $D_Flag, F_Reg // Decimal mode? maybe_DoADC_d
jnz CALL(op_ADC_dec) // Yes, jump to decimal version
DoADC_b DoADC_b
Continue Continue
ENTRY(op_ADC_ind_y) // 0x71 ENTRY(op_ADC_ind_y) // 0x71
GetIndZPage_Y GetIndZPage_Y
testb $D_Flag, F_Reg // Decimal mode? maybe_DoADC_d
jnz CALL(op_ADC_dec) // Yes, jump to decimal version
DoADC_b DoADC_b
Continue Continue
// 65c02 : 0x72 // 65c02 : 0x72
ENTRY(op_ADC_ind_zpage) ENTRY(op_ADC_ind_zpage)
GetIndZPage GetIndZPage
testb $D_Flag, F_Reg // Decimal mode? maybe_DoADC_d
jnz CALL(op_ADC_dec) // Yes, jump to decimal version
DoADC_b DoADC_b
Continue Continue
@ -1532,7 +1516,7 @@ ENTRY(op_PHX)
ENTRY(op_PHY) ENTRY(op_PHY)
#ifdef APPLE_ASSEMBLER_IS_BROKEN #ifdef APPLE_ASSEMBLER_IS_BROKEN
movb Y_Reg, %al movb Y_Reg, %al
Push(%al) Push(%al)
#else #else
Push(Y_Reg) Push(Y_Reg)
@ -1572,7 +1556,7 @@ ENTRY(op_PLP) // 0x28
ENTRY(op_PLX) ENTRY(op_PLX)
Pop(X_Reg) Pop(X_Reg)
orb X_Reg, X_Reg orb X_Reg, X_Reg
FlagNZ FlagNZ
Continue Continue
@ -1588,7 +1572,7 @@ ENTRY(op_PLY)
#else #else
Pop(Y_Reg) Pop(Y_Reg)
#endif #endif
orb Y_Reg, Y_Reg orb Y_Reg, Y_Reg
FlagNZ FlagNZ
Continue Continue
@ -1683,7 +1667,6 @@ ENTRY(op_RTI) // 0x40
---------------------------------- */ ---------------------------------- */
ENTRY(op_RTS) // 0x60 ENTRY(op_RTS) // 0x60
Pop(%al) Pop(%al)
#ifdef APPLE_ASSEMBLER_IS_BROKEN #ifdef APPLE_ASSEMBLER_IS_BROKEN
shlw $8, %ax shlw $8, %ax
@ -1758,24 +1741,25 @@ _das_finish: popq _XBX
#endif #endif
Continue Continue
#define maybe_DoSBC_d \
testb $D_Flag, F_Reg; /* Decimal mode? */ \
jnz CALL(op_SBC_dec) /* Yes, jump to decimal version */
ENTRY(op_SBC_imm) // 0xe9 ENTRY(op_SBC_imm) // 0xe9
GetImm GetImm
testb $D_Flag, F_Reg // Decimal mode? maybe_DoSBC_d
jnz CALL(op_SBC_dec) // Yes, jump to decimal version
DoSBC_b DoSBC_b
Continue Continue
ENTRY(op_SBC_zpage) // 0xe5 ENTRY(op_SBC_zpage) // 0xe5
GetZPage GetZPage
testb $D_Flag, F_Reg // Decimal mode? maybe_DoSBC_d
jnz CALL(op_SBC_dec) // Yes, jump to decimal version
DoSBC_b DoSBC_b
Continue Continue
ENTRY(op_SBC_zpage_x) // 0xf5 ENTRY(op_SBC_zpage_x) // 0xf5
GetZPage_X GetZPage_X
testb $D_Flag, F_Reg // Decimal mode? maybe_DoSBC_d
jnz CALL(op_SBC_dec) // Yes, jump to decimal version
DoSBC_b DoSBC_b
Continue Continue
@ -1785,44 +1769,38 @@ ENTRY(op_SBC_zpage_y)
ENTRY(op_SBC_abs) // 0xed ENTRY(op_SBC_abs) // 0xed
GetAbs GetAbs
testb $D_Flag, F_Reg // Decimal mode? maybe_DoSBC_d
jnz CALL(op_SBC_dec) // Yes, jump to decimal version
DoSBC_b DoSBC_b
Continue Continue
ENTRY(op_SBC_abs_x) // 0xfd ENTRY(op_SBC_abs_x) // 0xfd
GetAbs_X GetAbs_X
testb $D_Flag, F_Reg // Decimal mode? maybe_DoSBC_d
jnz CALL(op_SBC_dec) // Yes, jump to decimal version
DoSBC_b DoSBC_b
Continue Continue
ENTRY(op_SBC_abs_y) // 0xf9 ENTRY(op_SBC_abs_y) // 0xf9
GetAbs_Y GetAbs_Y
testb $D_Flag, F_Reg // Decimal mode? maybe_DoSBC_d
jnz CALL(op_SBC_dec) // Yes, jump to decimal version
DoSBC_b DoSBC_b
Continue Continue
ENTRY(op_SBC_ind_x) // 0xe1 ENTRY(op_SBC_ind_x) // 0xe1
GetIndZPage_X GetIndZPage_X
testb $D_Flag, F_Reg // Decimal mode? maybe_DoSBC_d
jnz CALL(op_SBC_dec) // Yes, jump to decimal version
DoSBC_b DoSBC_b
Continue Continue
ENTRY(op_SBC_ind_y) // 0xf1 ENTRY(op_SBC_ind_y) // 0xf1
GetIndZPage_Y GetIndZPage_Y
testb $D_Flag, F_Reg // Decimal mode? maybe_DoSBC_d
jnz CALL(op_SBC_dec) // Yes, jump to decimal version
DoSBC_b DoSBC_b
Continue Continue
// 65c02 : 0xF2 // 65c02 : 0xF2
ENTRY(op_SBC_ind_zpage) ENTRY(op_SBC_ind_zpage)
GetIndZPage GetIndZPage
testb $D_Flag, F_Reg // Decimal mode? maybe_DoSBC_d
jnz CALL(op_SBC_dec) // Yes, jump to decimal version
DoSBC_b DoSBC_b
Continue Continue