From 8aa138de854e29213355395d9b30ff95ed9d3f27 Mon Sep 17 00:00:00 2001
From: AnonymusRaccoon
Date: Thu, 13 Feb 2020 11:23:36 +0100
Subject: [PATCH] Finishing the STA
---
sources/CPU/CPU.hpp | 12 ++++++------
tests/CPU/testStore.cpp | 30 ++++++++++++++++++++----------
2 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/sources/CPU/CPU.hpp b/sources/CPU/CPU.hpp
index f74a8bf..6980eea 100644
--- a/sources/CPU/CPU.hpp
+++ b/sources/CPU/CPU.hpp
@@ -18,8 +18,8 @@ namespace ComSquare::CPU
//! @brief The Accumulator
union {
struct {
- uint8_t ah;
uint8_t al;
+ uint8_t ah;
};
uint16_t a;
};
@@ -28,8 +28,8 @@ namespace ComSquare::CPU
//! @brief The Direct Page register;
union {
struct {
- uint8_t dh;
uint8_t dl;
+ uint8_t dh;
};
uint16_t d;
};
@@ -40,8 +40,8 @@ namespace ComSquare::CPU
//! @brief The Program Counter;
union {
struct {
- uint8_t pch;
uint8_t pcl;
+ uint8_t pch;
};
uint16_t pc;
};
@@ -52,24 +52,24 @@ namespace ComSquare::CPU
//! @brief The Stack pointer
union {
struct {
- uint8_t sh;
uint8_t sl;
+ uint8_t sh;
};
uint16_t s;
};
//! @brief The X index register
union {
struct {
- uint8_t xh;
uint8_t xl;
+ uint8_t xh;
};
uint16_t x;
};
//! @brief The Y index register
union {
struct {
- uint8_t yh;
uint8_t yl;
+ uint8_t yh;
};
uint16_t y;
};
diff --git a/tests/CPU/testStore.cpp b/tests/CPU/testStore.cpp
index 914ecfc..c344c78 100644
--- a/tests/CPU/testStore.cpp
+++ b/tests/CPU/testStore.cpp
@@ -8,13 +8,23 @@
#include "../tests.hpp"
#include "../../sources/SNES.hpp"
using namespace ComSquare;
-//
-//Test(STA, 8bits)
-//{
-// auto pair = Init();
-// pair.second.cpu->_registers.p.m = false;
-// pair.second.cpu->_registers.a = 0x11;
-// pair.second.cpu->STA(0x0);
-// auto data = pair.second.wram->_data[0];
-// cr_assert_eq(data, 0x11, "The stored value should be 0x11 but it was 0x%x.", data);
-//}
\ No newline at end of file
+
+Test(STA, 8bits)
+{
+ auto pair = Init();
+ pair.second.cpu->_registers.p.m = true;
+ pair.second.cpu->_registers.a = 0x11;
+ pair.second.cpu->STA(0x0);
+ auto data = pair.second.wram->_data[0];
+ cr_assert_eq(data, 0x11, "The stored value should be 0x11 but it was 0x%x.", data);
+}
+
+Test(STA, 16bits)
+{
+ auto pair = Init();
+ pair.second.cpu->_registers.p.m = false;
+ pair.second.cpu->_registers.a = 0x11AB;
+ pair.second.cpu->STA(0x0);
+ auto data = pair.second.wram->_data[0] + (pair.second.wram->_data[1] << 8u);
+ cr_assert_eq(data, 0x11AB, "The stored value should be 0x11AB but it was 0x%x.", data);
+}
\ No newline at end of file