gipu/cpp/vm.h
Giulio De Pasquale ffb11f9a2e reg2reg assembler
2017-05-17 18:58:00 +02:00

48 lines
830 B
C++

#ifndef VM_H
#define VM_H
#include "vmas.h"
#include <stdint.h>
enum regs { R0, R1, R2, R3, S0, S1, S2, S3, IP, BP, SP, NUM_REGS };
class VM {
private:
////////////////////////
// VARIABLES
////////////////////////
uint16_t regs[0xb];
struct flags {
uint8_t zf : 1;
uint8_t cf : 1;
};
VMAddrSpace as;
////////////////////////
// FUNCTIONS
///////////////////////
void initVariables(void);
void defineOpcodes(uint8_t *key);
/*
DBG UTILS
*/
uint8_t *getRegName(uint8_t);
/*
IMPLEMENTATIONS
*/
bool execMOVI(void);
bool execMOVR(void);
bool execMOVM(void);
bool execLOAD(void);
bool execSTOR(void);
bool execADDI(void);
void execADDR(void);
public:
VM(uint8_t *key);
VM(uint8_t *key, uint8_t *code, uint32_t codesize);
void status(void);
void run();
};
#endif