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
|
|
|
|
{
|
2024-05-19 09:07:20 +01:00
|
|
|
|
public abstract class BigEndianProcessor(Bus memory) : Processor(memory)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2019-02-14 23:01:31 +00:00
|
|
|
|
public override Register16 PeekWord(ushort address)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2024-06-29 13:38:55 +01: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 04:47:36 +01: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
|
|
|
|
{
|
2024-06-29 13:38:55 +01: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
|
|
|
|
{
|
2024-06-29 13:38:55 +01:00
|
|
|
|
this.Intermediate.High = this.MemoryRead();
|
2019-02-21 19:58:49 +00:00
|
|
|
|
++this.Bus.Address.Word;
|
2024-06-29 13:38:55 +01:00
|
|
|
|
this.Intermediate.Low = this.MemoryRead();
|
|
|
|
|
return this.Intermediate;
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 13:59:37 +01:00
|
|
|
|
protected override Register16 GetWordPaged()
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2024-06-29 13:38:55 +01:00
|
|
|
|
this.Intermediate.High = this.MemoryRead();
|
2024-05-28 13:59:37 +01:00
|
|
|
|
++this.Bus.Address.Low;
|
2024-06-29 13:38:55 +01:00
|
|
|
|
this.Intermediate.Low = this.MemoryRead();
|
|
|
|
|
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
|
|
|
|
{
|
2024-06-29 13:38:55 +01: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
|
|
|
|
{
|
2020-07-05 00:09:51 +01:00
|
|
|
|
this.MemoryWrite(value.High);
|
2019-02-21 19:58:49 +00:00
|
|
|
|
++this.Bus.Address.Word;
|
2020-07-05 00:09:51 +01:00
|
|
|
|
this.MemoryWrite(value.Low);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 13:59:37 +01:00
|
|
|
|
protected override void SetWordPaged(Register16 value)
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
2024-05-28 13:59:37 +01:00
|
|
|
|
this.MemoryWrite(value.High);
|
|
|
|
|
++this.Bus.Address.Low;
|
|
|
|
|
this.MemoryWrite(value.Low);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
2024-05-28 13:59:37 +01:00
|
|
|
|
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|