mirror of
https://github.com/cc65/cc65.git
synced 2025-01-01 03:30:20 +00:00
Merge pull request #2569 from sidneycadot/fix-cpu-register-types
sim65: tighten 6502 register types
This commit is contained in:
commit
075514c60c
@ -664,15 +664,12 @@ static unsigned HaveIRQRequest;
|
|||||||
|
|
||||||
|
|
||||||
/* ADC, binary mode (6502 and 65C02) */
|
/* ADC, binary mode (6502 and 65C02) */
|
||||||
/* TODO: once the Regs fields are properly sized, get rid of the
|
|
||||||
* "& 0xff" in the Regs.AC asignment.
|
|
||||||
*/
|
|
||||||
#define ADC_BINARY_MODE(v) \
|
#define ADC_BINARY_MODE(v) \
|
||||||
do { \
|
do { \
|
||||||
const uint8_t op = v; \
|
const uint8_t op = v; \
|
||||||
const uint8_t OldAC = Regs.AC; \
|
const uint8_t OldAC = Regs.AC; \
|
||||||
bool carry = GET_CF(); \
|
bool carry = GET_CF(); \
|
||||||
Regs.AC = (OldAC + op + carry) & 0xff; \
|
Regs.AC = (OldAC + op + carry); \
|
||||||
const bool NV = Regs.AC >= 0x80; \
|
const bool NV = Regs.AC >= 0x80; \
|
||||||
carry = OldAC + op + carry >= 0x100; \
|
carry = OldAC + op + carry >= 0x100; \
|
||||||
SET_SF(NV); \
|
SET_SF(NV); \
|
||||||
@ -1033,15 +1030,12 @@ static unsigned HaveIRQRequest;
|
|||||||
TEST_ZF (Val)
|
TEST_ZF (Val)
|
||||||
|
|
||||||
/* SBC, binary mode (6502 and 65C02) */
|
/* SBC, binary mode (6502 and 65C02) */
|
||||||
/* TODO: once the Regs fields are properly sized, get rid of the
|
|
||||||
* "& 0xff" in the Regs.AC asignment.
|
|
||||||
*/
|
|
||||||
#define SBC_BINARY_MODE(v) \
|
#define SBC_BINARY_MODE(v) \
|
||||||
do { \
|
do { \
|
||||||
const uint8_t op = v; \
|
const uint8_t op = v; \
|
||||||
const uint8_t OldAC = Regs.AC; \
|
const uint8_t OldAC = Regs.AC; \
|
||||||
const bool borrow = !GET_CF(); \
|
const bool borrow = !GET_CF(); \
|
||||||
Regs.AC = (OldAC - op - borrow) & 0xff; \
|
Regs.AC = (OldAC - op - borrow); \
|
||||||
const bool NV = Regs.AC >= 0x80; \
|
const bool NV = Regs.AC >= 0x80; \
|
||||||
SET_SF(NV); \
|
SET_SF(NV); \
|
||||||
SET_OF(((OldAC >= 0x80) ^ NV) & ((op < 0x80) ^ NV)); \
|
SET_OF(((OldAC >= 0x80) ^ NV) & ((op < 0x80) ^ NV)); \
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
#define _6502_H
|
#define _6502_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Data */
|
/* Data */
|
||||||
@ -57,12 +59,12 @@ extern CPUType CPU;
|
|||||||
/* 6502 CPU registers */
|
/* 6502 CPU registers */
|
||||||
typedef struct CPURegs CPURegs;
|
typedef struct CPURegs CPURegs;
|
||||||
struct CPURegs {
|
struct CPURegs {
|
||||||
unsigned AC; /* Accumulator */
|
uint8_t AC; /* Accumulator */
|
||||||
unsigned XR; /* X register */
|
uint8_t XR; /* X register */
|
||||||
unsigned YR; /* Y register */
|
uint8_t YR; /* Y register */
|
||||||
unsigned SR; /* Status register */
|
uint8_t SR; /* Status register */
|
||||||
unsigned SP; /* Stackpointer */
|
uint8_t SP; /* Stackpointer */
|
||||||
unsigned PC; /* Program counter */
|
uint16_t PC; /* Program counter */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Current CPU registers */
|
/* Current CPU registers */
|
||||||
|
Loading…
Reference in New Issue
Block a user