Finishing to implements JSR/JLR and push

This commit is contained in:
AnonymusRaccoon
2020-02-14 15:20:19 +01:00
parent 31aa3c843e
commit 55d87bf9ac
5 changed files with 302 additions and 12 deletions
+48 -4
View File
@@ -34,8 +34,6 @@ namespace ComSquare::CPU
};
union {
struct {
//! @brief The Program Bank Register;
uint8_t pbr;
//! @brief The Program Counter;
union {
struct {
@@ -44,6 +42,8 @@ namespace ComSquare::CPU
};
uint16_t pc;
};
//! @brief The Program Bank Register;
uint8_t pbr;
};
//! @brief The current Program Address Counter (does not exist in a snes but is useful here).
uint24_t pac;
@@ -262,7 +262,19 @@ namespace ComSquare::CPU
SEP = 0xE2,
REP = 0xC2
REP = 0xC2,
PHA = 0x48,
PHB = 0x8B,
PHD = 0x0B,
PHK = 0x4B,
PHP = 0x08,
PHX = 0xDA,
PHY = 0x5A,
JSR_ABS = 0x20,
JSR_ABSXi = 0xFC,
JSL = 0x22
};
//! @brief The main CPU
@@ -313,7 +325,7 @@ namespace ComSquare::CPU
//! @brief 2 bytes are pulled from the <abs exp> to form the effective address.
uint24_t _getAbsoluteIndirectAddr();
//! @brief The <abs exp> is added with X, then 2 bytes are pulled from that address to form the new location.
uint24_t _getAbsoluteIndexedIndirectAddr();
uint24_t _getAbsoluteIndirectIndexedByXAddr();
//! @brief 2 bytes are pulled from the direct page address to form the 16-bit address. It is combined with DBR to form a 24-bit effective address.
uint24_t _getDirectIndirectAddr();
//! @brief 3 bytes are pulled from the direct page address to form an effective address.
@@ -365,6 +377,38 @@ namespace ComSquare::CPU
void SEP(uint24_t valueAddr);
//! @brief Reset status bits.
void REP(uint24_t valueAddr);
//! @brief Jump to subroutine
void JSR(uint24_t addr);
//! @brief Jump to subroutine (long)
void JSL(uint24_t addr);
//! @brief Push the accumulator to the stack.
void PHA();
//! @brief Push the data bank register to the stack.
void PHB();
//! @brief Push the direct page register to the stack.
void PHD();
//! @brief Push the program bank register to the stack.
void PHK();
//! @brief Push the processor status register to the stack.
void PHP();
//! @brief Push the x index register to the stack.
void PHX();
//! @brief Push the y index register to the stack.
void PHY();
//! @brief Pull the accumulator to the stack.
void PLA();
//! @brief Pull the data bank register to the stack.
void PLB();
//! @brief Pull the direct page register to the stack.
void PLD();
//! @brief Pull the program bank register to the stack.
void PLK();
//! @brief Pull the processor status register to the stack.
void PLP();
//! @brief Pull the x index register to the stack.
void PLX();
//! @brief Pull the y index register to the stack.
void PLY();
public:
explicit CPU(std::shared_ptr<Memory::MemoryBus> bus, Cartridge::Header &cartridgeHeader);
CPU(const CPU &) = default;