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
|
|
|
|
|
{
|
2019-02-21 22:52:46 +00:00
|
|
|
|
private readonly Register16 intermediate = new Register16();
|
|
|
|
|
|
2019-02-02 15:12:51 +00:00
|
|
|
|
protected BigEndianProcessor(Bus memory)
|
|
|
|
|
: base(memory)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-14 23:01:31 +00:00
|
|
|
|
public override Register16 PeekWord(ushort address)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-21 22:52:46 +00:00
|
|
|
|
this.intermediate.High = this.Bus.Peek(address);
|
|
|
|
|
this.intermediate.Low = this.Bus.Peek(++address);
|
|
|
|
|
return this.intermediate;
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-14 23:01:31 +00:00
|
|
|
|
public override void PokeWord(ushort address, Register16 value)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-04-21 03:47:36 +00:00
|
|
|
|
this.Bus.Poke(address, value.High);
|
|
|
|
|
this.Bus.Poke(++address, value.Low);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-14 23:01:31 +00:00
|
|
|
|
protected override Register16 FetchWord()
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-21 22:52:46 +00:00
|
|
|
|
this.intermediate.High = this.FetchByte();
|
|
|
|
|
this.intermediate.Low = this.FetchByte();
|
|
|
|
|
return this.intermediate;
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-14 23:01:31 +00:00
|
|
|
|
protected override Register16 GetWord()
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-21 22:52:46 +00:00
|
|
|
|
this.intermediate.High = this.BusRead();
|
2019-02-21 19:58:49 +00:00
|
|
|
|
++this.Bus.Address.Word;
|
2019-02-21 22:52:46 +00:00
|
|
|
|
this.intermediate.Low = this.BusRead();
|
|
|
|
|
return this.intermediate;
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-14 23:01:31 +00:00
|
|
|
|
protected override Register16 GetWordPaged(byte page, byte offset)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-21 22:52:46 +00:00
|
|
|
|
this.intermediate.High = this.BusRead(offset, page);
|
|
|
|
|
this.intermediate.Low = this.BusRead(++offset, page);
|
|
|
|
|
return this.intermediate;
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-14 23:01:31 +00:00
|
|
|
|
protected override Register16 PopWord()
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-21 22:52:46 +00:00
|
|
|
|
this.intermediate.High = this.Pop();
|
|
|
|
|
this.intermediate.Low = this.Pop();
|
|
|
|
|
return this.intermediate;
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-14 23:01:31 +00:00
|
|
|
|
protected override void PushWord(Register16 value)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-14 23:01:31 +00:00
|
|
|
|
this.Push(value.Low);
|
|
|
|
|
this.Push(value.High);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-14 23:01:31 +00:00
|
|
|
|
protected override void SetWord(Register16 value)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-14 23:01:31 +00:00
|
|
|
|
this.BusWrite(value.High);
|
2019-02-21 19:58:49 +00:00
|
|
|
|
++this.Bus.Address.Word;
|
2019-02-14 23:01:31 +00:00
|
|
|
|
this.BusWrite(value.Low);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-14 23:01:31 +00:00
|
|
|
|
protected override void SetWordPaged(byte page, byte offset, Register16 value)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-14 23:01:31 +00:00
|
|
|
|
this.BusWrite(offset, page, value.High);
|
|
|
|
|
this.BusWrite(++offset, page, value.Low);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|