2016-01-27 11:31:39 +00:00
|
|
|
//NEC V30MZ
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Processor {
|
|
|
|
|
|
|
|
struct V30MZ {
|
2016-01-31 07:59:44 +00:00
|
|
|
using Size = const uint&;
|
|
|
|
static const uint Byte;
|
|
|
|
static const uint Word;
|
|
|
|
|
2016-01-28 11:39:49 +00:00
|
|
|
virtual auto wait(uint clocks = 1) -> void = 0;
|
|
|
|
virtual auto read(uint20 addr) -> uint8 = 0;
|
|
|
|
virtual auto write(uint20 addr, uint8 data) -> void = 0;
|
2016-01-30 06:40:35 +00:00
|
|
|
virtual auto in(uint16 port) -> uint8 = 0;
|
|
|
|
virtual auto out(uint16 port, uint8 data) -> void = 0;
|
2016-01-27 11:31:39 +00:00
|
|
|
|
|
|
|
auto exec() -> void;
|
2016-01-28 11:39:49 +00:00
|
|
|
auto execOpcode() -> void;
|
2016-01-27 11:31:39 +00:00
|
|
|
auto power() -> void;
|
|
|
|
|
2016-01-30 06:40:35 +00:00
|
|
|
//registers.cpp
|
2016-01-31 07:59:44 +00:00
|
|
|
auto getRegister(Size, uint8) -> uint16;
|
|
|
|
auto setRegister(Size, uint8, uint16) -> void;
|
|
|
|
|
|
|
|
auto getSegment(uint8) -> uint16;
|
|
|
|
auto setSegment(uint8, uint16) -> void;
|
2016-01-30 06:40:35 +00:00
|
|
|
|
2016-01-28 11:39:49 +00:00
|
|
|
//memory.cpp
|
2016-01-31 07:59:44 +00:00
|
|
|
auto read(Size, uint16, uint16) -> uint16;
|
|
|
|
auto write(Size, uint16, uint16, uint16) -> void;
|
|
|
|
|
|
|
|
auto readIP(Size = Byte) -> uint16;
|
2016-01-30 06:40:35 +00:00
|
|
|
|
|
|
|
auto readSP() -> uint16;
|
|
|
|
auto writeSP(uint16) -> void;
|
|
|
|
|
2016-01-31 07:59:44 +00:00
|
|
|
auto readModRM(uint8) -> uint32;
|
|
|
|
auto readModRM(Size, uint8) -> uint16;
|
2016-01-30 06:40:35 +00:00
|
|
|
|
|
|
|
//algorithms.cpp
|
|
|
|
auto parity(uint16) const -> bool;
|
2016-01-31 07:59:44 +00:00
|
|
|
auto alAnd(Size, uint16, uint16) -> uint16;
|
2016-01-28 11:39:49 +00:00
|
|
|
|
|
|
|
//instructions.cpp
|
2016-01-31 07:59:44 +00:00
|
|
|
auto opXorRegisterModRM(Size);
|
2016-01-30 06:40:35 +00:00
|
|
|
auto opJumpIf(bool);
|
2016-01-31 07:59:44 +00:00
|
|
|
auto opMoveRegisterModRM(Size);
|
2016-01-30 06:40:35 +00:00
|
|
|
auto opMoveSegmentRegisterModRM();
|
2016-01-28 11:39:49 +00:00
|
|
|
auto opNoOperation();
|
2016-01-31 07:59:44 +00:00
|
|
|
auto opMoveString(Size);
|
|
|
|
auto opTestAX(Size);
|
|
|
|
auto opMoveRegisterImmediate(uint8&);
|
|
|
|
auto opMoveRegisterImmediate(uint16&);
|
2016-01-30 06:40:35 +00:00
|
|
|
auto opReturn();
|
2016-01-31 07:59:44 +00:00
|
|
|
auto opIn(Size);
|
|
|
|
auto opOut(Size);
|
2016-01-30 06:40:35 +00:00
|
|
|
auto opCallNear();
|
|
|
|
auto opJumpFar();
|
2016-01-31 07:59:44 +00:00
|
|
|
auto opInDX(Size);
|
|
|
|
auto opOutDX(Size);
|
|
|
|
auto opRepeat(bool);
|
2016-01-28 11:39:49 +00:00
|
|
|
auto opClearFlag(bool&);
|
|
|
|
auto opSetFlag(bool&);
|
|
|
|
|
|
|
|
//disassembler.cpp
|
|
|
|
auto disassemble(uint16 cs, uint16 ip, bool registers = true) -> string;
|
|
|
|
|
|
|
|
//state
|
|
|
|
bool halt = false;
|
|
|
|
uint executed = 0;
|
|
|
|
|
2016-01-27 11:31:39 +00:00
|
|
|
struct Registers {
|
2016-01-28 11:39:49 +00:00
|
|
|
uint16 ip;
|
2016-01-30 06:40:35 +00:00
|
|
|
union { uint16 ax; struct { uint8 order_lsb2(al, ah); }; };
|
|
|
|
union { uint16 bx; struct { uint8 order_lsb2(bl, bh); }; };
|
|
|
|
union { uint16 cx; struct { uint8 order_lsb2(cl, ch); }; };
|
|
|
|
union { uint16 dx; struct { uint8 order_lsb2(dl, dh); }; };
|
2016-01-27 11:31:39 +00:00
|
|
|
uint16 si;
|
|
|
|
uint16 di;
|
2016-01-28 11:39:49 +00:00
|
|
|
uint16 bp;
|
|
|
|
uint16 sp;
|
2016-01-27 11:31:39 +00:00
|
|
|
uint16 cs;
|
|
|
|
uint16 ds;
|
2016-01-28 11:39:49 +00:00
|
|
|
uint16 es;
|
|
|
|
uint16 ss;
|
2016-01-30 06:40:35 +00:00
|
|
|
|
2016-01-28 11:39:49 +00:00
|
|
|
struct Flags {
|
|
|
|
operator uint16() const;
|
|
|
|
auto operator=(uint16 data);
|
|
|
|
|
|
|
|
bool m; //mode
|
|
|
|
bool v; //overflow
|
|
|
|
bool d; //direction
|
|
|
|
bool i; //interrupt
|
|
|
|
bool b; //break
|
|
|
|
bool s; //sign
|
|
|
|
bool z; //zero
|
|
|
|
bool h; //half-carry
|
|
|
|
bool p; //parity
|
|
|
|
bool c; //carry
|
|
|
|
} f;
|
2016-01-27 11:31:39 +00:00
|
|
|
} r;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|