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
|
|
|
|
|
{
|
|
|
|
|
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-04 23:52:21 +00:00
|
|
|
|
var low = this.Bus.Peek(address);
|
|
|
|
|
var high = this.Bus.Peek(++address);
|
2019-02-14 23:01:31 +00:00
|
|
|
|
return new Register16(low, high);
|
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-04 23:52:21 +00:00
|
|
|
|
var low = this.FetchByte();
|
|
|
|
|
var high = this.FetchByte();
|
2019-02-14 23:01:31 +00:00
|
|
|
|
return new Register16(low, high);
|
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-04 23:52:21 +00:00
|
|
|
|
var low = this.BusRead();
|
2019-02-14 23:01:31 +00:00
|
|
|
|
++this.Bus.Address();
|
2019-02-04 23:52:21 +00:00
|
|
|
|
var high = this.BusRead();
|
2019-02-14 23:01:31 +00:00
|
|
|
|
return new Register16(low, high);
|
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-04 23:52:21 +00:00
|
|
|
|
var low = this.BusRead(offset, page);
|
2019-02-06 23:41:56 +00:00
|
|
|
|
var high = this.BusRead(++offset, page);
|
2019-02-14 23:01:31 +00:00
|
|
|
|
return new Register16(low, high);
|
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-04 23:52:21 +00:00
|
|
|
|
var low = this.Pop();
|
|
|
|
|
var high = this.Pop();
|
2019-02-14 23:01:31 +00:00
|
|
|
|
return new Register16(low, high);
|
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);
|
|
|
|
|
++this.Bus.Address();
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|