mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-08 12:10:34 +00:00
Adding Subroutine operations
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user