2019-02-04 23:52:21 +00:00
|
|
|
|
// <copyright file="BigEndianProcessor.cs" company="Adrian Conlon">
|
|
|
|
|
// Copyright (c) Adrian Conlon. All rights reserved.
|
|
|
|
|
// </copyright>
|
|
|
|
|
namespace EightBit
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
|
|
|
|
public abstract class BigEndianProcessor : Processor
|
|
|
|
|
{
|
|
|
|
|
protected BigEndianProcessor(Bus memory)
|
|
|
|
|
: base(memory)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 00:42:55 +00:00
|
|
|
|
public override ushort PeekWord(ushort address)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-04 23:52:21 +00:00
|
|
|
|
var high = this.Bus.Peek(address);
|
|
|
|
|
var low = this.Bus.Peek(++address);
|
|
|
|
|
return Chip.MakeWord(low, high);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 00:42:55 +00:00
|
|
|
|
public override void PokeWord(ushort address, ushort value)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-04 23:52:21 +00:00
|
|
|
|
this.Bus.Poke(address, Chip.LowByte(value));
|
|
|
|
|
this.Bus.Poke(++address, Chip.HighByte(value));
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 00:42:55 +00:00
|
|
|
|
protected override ushort FetchWord()
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-04 23:52:21 +00:00
|
|
|
|
var high = this.FetchByte();
|
|
|
|
|
var low = this.FetchByte();
|
|
|
|
|
return Chip.MakeWord(low, high);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 00:42:55 +00:00
|
|
|
|
protected override ushort GetWord()
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-04 23:52:21 +00:00
|
|
|
|
var high = this.BusRead();
|
|
|
|
|
++this.Bus.Address;
|
|
|
|
|
var low = this.BusRead();
|
|
|
|
|
return Chip.MakeWord(low, high);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 00:42:55 +00:00
|
|
|
|
protected override ushort GetWordPaged(byte page, byte offset)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-04 23:52:21 +00:00
|
|
|
|
var high = this.BusRead(offset, page);
|
2019-02-06 23:41:56 +00:00
|
|
|
|
var low = this.BusRead(++offset, page);
|
2019-02-04 23:52:21 +00:00
|
|
|
|
return Chip.MakeWord(low, high);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 00:42:55 +00:00
|
|
|
|
protected override ushort PopWord()
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-04 23:52:21 +00:00
|
|
|
|
var high = this.Pop();
|
|
|
|
|
var low = this.Pop();
|
|
|
|
|
return Chip.MakeWord(low, high);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 00:42:55 +00:00
|
|
|
|
protected override void PushWord(ushort value)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-04 23:52:21 +00:00
|
|
|
|
this.Push(Chip.LowByte(value));
|
|
|
|
|
this.Push(Chip.HighByte(value));
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 00:42:55 +00:00
|
|
|
|
protected override void SetWord(ushort value)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-04 23:52:21 +00:00
|
|
|
|
this.BusWrite(Chip.HighByte(value));
|
|
|
|
|
++this.Bus.Address;
|
|
|
|
|
this.BusWrite(Chip.LowByte(value));
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 00:42:55 +00:00
|
|
|
|
protected override void SetWordPaged(byte page, byte offset, ushort value)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-04 23:52:21 +00:00
|
|
|
|
this.BusWrite(offset, page, Chip.HighByte(value));
|
2019-02-06 23:41:56 +00:00
|
|
|
|
this.BusWrite(++offset, page, Chip.LowByte(value));
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|