2016-01-27 11:31:39 +00:00
|
|
|
//NEC V30MZ
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Processor {
|
|
|
|
|
|
|
|
struct V30MZ {
|
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
|
|
|
|
auto regb(uint8) -> uint8&;
|
|
|
|
auto regw(uint8) -> uint16&;
|
|
|
|
auto sreg(uint8) -> uint16&;
|
|
|
|
|
2016-01-28 11:39:49 +00:00
|
|
|
//memory.cpp
|
2016-01-30 06:40:35 +00:00
|
|
|
auto readbIP() -> uint8;
|
|
|
|
auto readwIP() -> uint16;
|
|
|
|
|
|
|
|
auto readSP() -> uint16;
|
|
|
|
auto writeSP(uint16) -> void;
|
|
|
|
|
|
|
|
auto readb(uint20 ea) -> uint8;
|
|
|
|
auto readw(uint20 ea) -> uint16;
|
|
|
|
|
|
|
|
auto readb(uint16 rs, uint16 ea) -> uint8;
|
|
|
|
auto readw(uint16 rs, uint16 ea) -> uint16;
|
|
|
|
|
|
|
|
auto readModRM(uint8) -> uint20;
|
|
|
|
auto readbModRM(uint8) -> uint8;
|
|
|
|
auto readwModRM(uint8) -> uint16;
|
|
|
|
|
|
|
|
//algorithms.cpp
|
|
|
|
auto parity(uint16) const -> bool;
|
|
|
|
|
|
|
|
auto albAnd(uint8, uint8) -> uint8;
|
|
|
|
auto alwAnd(uint16, uint16) -> uint16;
|
2016-01-28 11:39:49 +00:00
|
|
|
|
|
|
|
//instructions.cpp
|
2016-01-30 06:40:35 +00:00
|
|
|
auto opbXorRegisterModRM();
|
|
|
|
auto opwXorRegisterModRM();
|
|
|
|
auto opJumpIf(bool);
|
|
|
|
auto opbMoveRegisterModRM();
|
|
|
|
auto opwMoveRegisterModRM();
|
|
|
|
auto opMoveSegmentRegisterModRM();
|
2016-01-28 11:39:49 +00:00
|
|
|
auto opNoOperation();
|
2016-01-30 06:40:35 +00:00
|
|
|
auto opTestAL();
|
|
|
|
auto opTestAX();
|
|
|
|
auto opbMoveRegisterImmediate(uint8&);
|
|
|
|
auto opwMoveRegisterImmediate(uint16&);
|
|
|
|
auto opReturn();
|
|
|
|
auto opbIn();
|
|
|
|
auto opwIn();
|
|
|
|
auto opbOut();
|
|
|
|
auto opwOut();
|
|
|
|
auto opCallNear();
|
|
|
|
auto opJumpFar();
|
|
|
|
auto opbInDX();
|
|
|
|
auto opwInDX();
|
|
|
|
auto opbOutDX();
|
|
|
|
auto opwOutDX();
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|