gipu/cpp/vm.h

48 lines
830 B
C
Raw Normal View History

2017-05-13 18:36:46 +01:00
#ifndef VM_H
#define VM_H
2017-05-14 13:06:17 +01:00
#include "vmas.h"
2017-05-14 21:10:58 +01:00
#include <stdint.h>
2017-05-13 18:36:46 +01:00
2017-05-17 17:32:05 +01:00
enum regs { R0, R1, R2, R3, S0, S1, S2, S3, IP, BP, SP, NUM_REGS };
2017-05-13 18:36:46 +01:00
class VM {
2017-05-14 21:10:58 +01:00
private:
////////////////////////
// VARIABLES
////////////////////////
2017-05-14 13:06:17 +01:00
uint16_t regs[0xb];
struct flags {
uint8_t zf : 1;
uint8_t cf : 1;
};
VMAddrSpace as;
2017-05-15 11:49:11 +01:00
////////////////////////
// FUNCTIONS
///////////////////////
void initVariables(void);
2017-05-17 17:58:00 +01:00
void defineOpcodes(uint8_t *key);
2017-05-15 11:49:11 +01:00
/*
DBG UTILS
*/
2017-05-17 17:58:00 +01:00
uint8_t *getRegName(uint8_t);
2017-05-14 21:10:58 +01:00
/*
IMPLEMENTATIONS
*/
2017-05-17 17:58:00 +01:00
bool execMOVI(void);
bool execMOVR(void);
bool execMOVM(void);
bool execLOAD(void);
bool execSTOR(void);
bool execADDI(void);
void execADDR(void);
2017-05-13 18:36:46 +01:00
2017-05-14 13:06:17 +01:00
public:
2017-05-17 17:58:00 +01:00
VM(uint8_t *key);
VM(uint8_t *key, uint8_t *code, uint32_t codesize);
2017-05-14 13:06:17 +01:00
void status(void);
2017-05-14 21:10:58 +01:00
void run();
2017-05-13 18:36:46 +01:00
};
#endif