mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-01-11 07:30:10 +00:00
3c5e292eae
Now runs some instructions before going wrong... Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
72 lines
1.9 KiB
C#
72 lines
1.9 KiB
C#
namespace EightBit
|
|
{
|
|
public abstract class BigEndianProcessor : Processor
|
|
{
|
|
protected BigEndianProcessor(Bus memory)
|
|
: base(memory)
|
|
{
|
|
}
|
|
|
|
public override ushort PeekWord(ushort address)
|
|
{
|
|
var high = Bus.Peek(address);
|
|
var low = Bus.Peek(++address);
|
|
return MakeWord(low, high);
|
|
}
|
|
|
|
public override void PokeWord(ushort address, ushort value)
|
|
{
|
|
Bus.Poke(address, LowByte(value));
|
|
Bus.Poke(++address, HighByte(value));
|
|
}
|
|
|
|
protected override ushort FetchWord()
|
|
{
|
|
var high = FetchByte();
|
|
var low = FetchByte();
|
|
return MakeWord(low, high);
|
|
}
|
|
|
|
protected override ushort GetWord()
|
|
{
|
|
var high = BusRead();
|
|
++Bus.Address;
|
|
var low = BusRead();
|
|
return MakeWord(low, high);
|
|
}
|
|
|
|
protected override ushort GetWordPaged(byte page, byte offset)
|
|
{
|
|
var high = GetBytePaged(page, offset);
|
|
var low = GetBytePaged(page, (byte)(offset + 1));
|
|
return MakeWord(low, high);
|
|
}
|
|
|
|
protected override ushort PopWord()
|
|
{
|
|
var high = Pop();
|
|
var low = Pop();
|
|
return MakeWord(low, high);
|
|
}
|
|
|
|
protected override void PushWord(ushort value)
|
|
{
|
|
Push(LowByte(value));
|
|
Push(HighByte(value));
|
|
}
|
|
|
|
protected override void SetWord(ushort value)
|
|
{
|
|
BusWrite(HighByte(value));
|
|
++Bus.Address;
|
|
BusWrite(LowByte(value));
|
|
}
|
|
|
|
protected override void SetWordPaged(byte page, byte offset, ushort value)
|
|
{
|
|
SetBytePaged(page, offset, HighByte(value));
|
|
SetBytePaged(page, (byte)(offset + 1), LowByte(value));
|
|
}
|
|
}
|
|
}
|