Add the overall emulation pipeline, w/ T
This commit is contained in:
parent
78d1f5588f
commit
46c1b42c53
@ -1,3 +1,5 @@
|
||||
#ifndef __A64INSTRUCTION__
|
||||
#define __A64INSTRUCTION__
|
||||
#include "a64instruction_DPImmediate.h"
|
||||
#include "a64instruction_Branch.h"
|
||||
#include "a64instruction_SingleTransfer.h"
|
||||
@ -22,3 +24,5 @@ typedef struct {
|
||||
a64inst_SingleTransferData SingleTransferData;
|
||||
} data;
|
||||
} a64inst_instruction;
|
||||
|
||||
#endif
|
||||
|
||||
@ -69,5 +69,3 @@
|
||||
#define BRANCH_CONDITIONAL_COND_MSB 4
|
||||
#define BRANCH_CONDITIONAL_OFFSET_LSB 5
|
||||
#define BRANCH_CONDITIONAL_OFFSET_MSB 24
|
||||
|
||||
a64inst_instruction *decode(word w);
|
||||
@ -1,5 +1,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "emulator.h"
|
||||
#include "fileio.h"
|
||||
#include "print.h"
|
||||
#include "decode.h"
|
||||
#include "execute.h"
|
||||
|
||||
extern a64inst_instruction *decode(word w);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
@ -18,6 +25,28 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
// Initialising the machine state
|
||||
Machine *state = {0};
|
||||
state->memory = fileio_loadBin(argv[1], MEMORY_SIZE);
|
||||
state->conditionCodes = (PState){0, 1, 0, 0};
|
||||
state->pc = 0x0;
|
||||
|
||||
// get
|
||||
a64inst_instruction *inst;
|
||||
|
||||
do {
|
||||
|
||||
word instruction = readWord(state, state->pc);
|
||||
inst = decode(instruction);
|
||||
execute(state, inst);
|
||||
|
||||
state->pc += 1;
|
||||
|
||||
} while (inst->type != a64inst_HALT);
|
||||
|
||||
printState(state, out);
|
||||
|
||||
free(state->memory);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#ifndef __EMULATOR__
|
||||
#define __EMULATOR__
|
||||
#include "global.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/************************************
|
||||
* DEFINITIONS
|
||||
@ -23,7 +24,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
word registers[REGISTER_COUNT];
|
||||
word pc;
|
||||
byte memory[MEMORY_SIZE];
|
||||
byte *memory;
|
||||
PState conditionCodes;
|
||||
} Machine;
|
||||
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
#include "execute.h"
|
||||
|
||||
void execute(a64inst_instruction inst) {
|
||||
void execute(Machine *state, a64inst_instruction *inst) {
|
||||
|
||||
switch (inst.type) {
|
||||
case a64inst_Halt:
|
||||
switch (inst->type) {
|
||||
case a64inst_HALT:
|
||||
// Halt the program
|
||||
break;
|
||||
case a64inst_DPImmediate:
|
||||
case a64inst_DPIMMEDIATE:
|
||||
// Execute a data processing immediate instruction
|
||||
break;
|
||||
case a64inst_Branch:
|
||||
case a64inst_BRANCH:
|
||||
// Execute a branch instruction
|
||||
break;
|
||||
case a64inst_DPRegister:
|
||||
case a64inst_DPREGISTER:
|
||||
// Execute a data processing register instruction
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
#ifndef __EXECUTE__
|
||||
#define __EXECUTE__
|
||||
#include "a64instruction.h"
|
||||
#include "emulator.h"
|
||||
|
||||
void execute(a64inst_instruction inst);
|
||||
void execute(Machine *state, a64inst_instruction *inst);
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user