2016-05-29 18:13:24 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/* Virtual machine state */
|
|
|
|
struct lilith
|
|
|
|
{
|
|
|
|
uint8_t *memory;
|
2016-05-30 15:58:23 +01:00
|
|
|
uint32_t reg[16];
|
|
|
|
uint32_t ip;
|
2016-05-29 18:13:24 +01:00
|
|
|
bool halted;
|
|
|
|
bool exception;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Unpacked instruction */
|
|
|
|
struct Instruction
|
|
|
|
{
|
2016-05-30 15:58:23 +01:00
|
|
|
uint32_t ip;
|
2016-05-29 18:13:24 +01:00
|
|
|
uint8_t raw0, raw1, raw2, raw3;
|
|
|
|
char opcode[3];
|
|
|
|
uint32_t raw_XOP;
|
|
|
|
char XOP[6];
|
|
|
|
char operation[9];
|
2016-06-05 17:44:37 +01:00
|
|
|
int16_t raw_Immediate;
|
2016-05-29 18:13:24 +01:00
|
|
|
char Immediate[7];
|
|
|
|
uint32_t HAL_CODE;
|
|
|
|
uint8_t reg0;
|
|
|
|
uint8_t reg1;
|
|
|
|
uint8_t reg2;
|
|
|
|
uint8_t reg3;
|
|
|
|
bool invalid;
|
|
|
|
};
|