2019-02-04 23:52:21 +00:00
|
|
|
|
// <copyright file="LittleEndianProcessor.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 LittleEndianProcessor : Processor
|
|
|
|
|
{
|
2019-02-21 22:52:46 +00:00
|
|
|
|
private readonly Register16 intermediate = new Register16();
|
|
|
|
|
|
2019-02-02 15:12:51 +00:00
|
|
|
|
protected LittleEndianProcessor(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.Low = this.Bus.Peek(address);
|
|
|
|
|
this.intermediate.High = 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-02-14 23:01:31 +00:00
|
|
|
|
this.Bus.Poke(address, value.Low);
|
|
|
|
|
this.Bus.Poke(++address, value.High);
|
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.Low = this.FetchByte();
|
|
|
|
|
this.intermediate.High = 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.Low = this.BusRead();
|
2019-02-21 19:58:49 +00:00
|
|
|
|
++this.Bus.Address.Word;
|
2019-02-21 22:52:46 +00:00
|
|
|
|
this.intermediate.High = 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.Low = this.BusRead(offset, page);
|
|
|
|
|
this.intermediate.High = 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.Low = this.Pop();
|
|
|
|
|
this.intermediate.High = 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.High);
|
|
|
|
|
this.Push(value.Low);
|
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.Low);
|
2019-02-21 19:58:49 +00:00
|
|
|
|
++this.Bus.Address.Word;
|
2019-02-14 23:01:31 +00:00
|
|
|
|
this.BusWrite(value.High);
|
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.Low);
|
|
|
|
|
this.BusWrite(++offset, page, value.High);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|