parent
23e861ad54
commit
bf59ce8dcd
2 changed files with 8 additions and 13 deletions
|
@ -5,8 +5,13 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct CPU_s {
|
struct CPU_s {
|
||||||
|
// [32] of 32bit (uint32_t) registers
|
||||||
uint32_t registers[32];
|
uint32_t registers[32];
|
||||||
|
|
||||||
|
// Points to the byte of current instruction. Also known as pc
|
||||||
uint32_t programCounter;
|
uint32_t programCounter;
|
||||||
|
|
||||||
|
// The address space
|
||||||
AddressSpace *addressSpace;
|
AddressSpace *addressSpace;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
16
src/cpu.c
16
src/cpu.c
|
@ -1,25 +1,15 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "cpu.h" // for structs
|
||||||
#include "address_space.h"
|
#include "address_space.h"
|
||||||
#include "instruction_executor.h"
|
#include "instruction_executor.h"
|
||||||
|
|
||||||
struct CPU_s {
|
const CPU cpu_default = {
|
||||||
// [32] of 32bit (uint32_t) registers
|
|
||||||
uint32_t registers[32];
|
|
||||||
|
|
||||||
// Points to the byte of current instruction. Also known as pc
|
|
||||||
uint32_t programCounter;
|
|
||||||
|
|
||||||
// The address space
|
|
||||||
AddressSpace *addressSpace;
|
|
||||||
} cpu_default = {
|
|
||||||
.registers = {0},
|
.registers = {0},
|
||||||
.programCounter = 0
|
.programCounter = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct CPU_s CPU;
|
|
||||||
|
|
||||||
|
|
||||||
CPU create_cpu(AddressSpace *addressSpace) {
|
CPU create_cpu(AddressSpace *addressSpace) {
|
||||||
CPU cpu = cpu_default;
|
CPU cpu = cpu_default;
|
||||||
cpu.addressSpace = addressSpace;
|
cpu.addressSpace = addressSpace;
|
||||||
|
|
Loading…
Reference in a new issue