Adding Subroutine operations

This commit is contained in:
Melefo
2020-02-21 14:54:31 +01:00
parent 35d6bdb84d
commit b1fc2754eb
6 changed files with 212 additions and 5 deletions
+2 -2
View File
@@ -8,13 +8,13 @@ namespace ComSquare::APU
{
int APU::PUSH(uint8_t value)
{
this->_internalWrite(this->_internalRegisters.sp-- | 0x0100u, value);
this->_internalWrite(this->_internalRegisters.sp-- + 0x0100u, value);
return 4;
}
int APU::POP(uint8_t &destination)
{
destination = this->_internalRead(++this->_internalRegisters.sp | 0x100u);
destination = this->_internalRead(++this->_internalRegisters.sp + 0x100u);
return 4;
}
}
+55
View File
@@ -0,0 +1,55 @@
//
// Created by Melefo on 21/02/2020.
//
#include "../APU.hpp"
#include "../../Utility/Utility.hpp"
namespace ComSquare::APU
{
int APU::CALL(uint24_t abs)
{
this->PUSH(this->_internalRegisters.pch);
this->PUSH(this->_internalRegisters.pcl);
this->_internalRegisters.pc = abs;
return 8;
}
int APU::PCALL()
{
this->CALL(0xFF00u + this->_internalRead(this->_internalRegisters.pc++));
return 6;
}
int APU::TCALL(uint8_t bit)
{
this->CALL(this->_internalRead(0xFFDE - bit * 2));
return 8;
}
int APU::BRK()
{
this->_internalRegisters.b = true;
this->PUSH(this->_internalRegisters.pch);
this->PUSH(this->_internalRegisters.pcl);
this->PUSH(this->_internalRegisters.psw);
this->_internalRegisters.i = false;
this->_internalRegisters.pch = this->_internalRead(0xFFDF);
this->_internalRegisters.pcl = this->_internalRead(0xFFDE);
return 8;
}
int APU::RET()
{
this->POP(this->_internalRegisters.pch);
this->POP(this->_internalRegisters.pcl);
return 5;
}
int APU::RETI()
{
this->POP(this->_internalRegisters.psw);
this->RET();
return 6;
}
}