60 lines
949 B
C++
60 lines
949 B
C++
#pragma once
|
|
|
|
#include <spider/SpiderRuntime.hpp>
|
|
|
|
namespace spider {
|
|
|
|
/**
|
|
* Implements an instruction reel.
|
|
*/
|
|
class InstrReel {
|
|
private:
|
|
|
|
public:
|
|
|
|
InstrReel();
|
|
|
|
~InstrReel();
|
|
|
|
public:
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
* Returns the two-byte instruction at the
|
|
* specific byte location.
|
|
*/
|
|
u16 instrAt(u64 ip) const;
|
|
|
|
/**
|
|
* Obtains a byte of data at
|
|
* the specific location.
|
|
*/
|
|
u8 dataAt(u64 ip) const;
|
|
|
|
public:
|
|
|
|
/**
|
|
* Fetches the data, and then
|
|
* feeds the instruction into the
|
|
* CPU.
|
|
*
|
|
* Returns how many steps it should
|
|
* move after.
|
|
*/
|
|
u8 feedNext(CPU& cpu);
|
|
|
|
public: // Static Utils //
|
|
|
|
static u16 unpackInstr(u16 bcode);
|
|
|
|
static u8 unpackAddrMode(u16 bcode);
|
|
|
|
static u8 unpackTypeSize(u16 bcode);
|
|
|
|
};
|
|
|
|
}
|