change operands for some instructions and start work on devices
This commit is contained in:
12
src/device.c
Normal file
12
src/device.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "device.h"
|
||||
|
||||
Device* createDevice(
|
||||
const char* name,
|
||||
void (*sendToDevice)(uint16_t number),
|
||||
uint16_t (*receiveFromDevice)(),
|
||||
void (*update)()
|
||||
) {
|
||||
Device* new = malloc(sizeof(Device));
|
||||
if (!new)
|
||||
return NULL;
|
||||
}
|
||||
15
src/device.h
15
src/device.h
@@ -1,5 +1,18 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct {
|
||||
char name[32];
|
||||
|
||||
} Device;
|
||||
void (*sendToDevice)(uint16_t number);
|
||||
uint16_t (*receiveFromDevice)();
|
||||
void (*update)();
|
||||
} Device;
|
||||
|
||||
Device* createDevice(
|
||||
const char* name,
|
||||
void (*sendToDevice)(uint16_t number),
|
||||
uint16_t (*receiveFromDevice)(),
|
||||
void (*update)()
|
||||
);
|
||||
@@ -13,7 +13,7 @@ const OperandType INSTRUCTION_OPERAND_TYPES[][3] = {
|
||||
{OP_REG, OP_REG, OP_REG}, // SHF
|
||||
{OP_REG, OP_REG, OP_NONE}, // JMP
|
||||
{OP_REG, OP_REG, OP_NONE}, // JIZ
|
||||
{OP_REG, OP_REG, OP_NONE}, // CALL
|
||||
{OP_IMM16, OP_NONE, OP_NONE},// CALL
|
||||
{OP_NONE, OP_NONE, OP_NONE}, // RET
|
||||
{OP_REG, OP_REG, OP_IMM4}, // PORT
|
||||
{OP_NONE, OP_NONE, OP_NONE} // HLT
|
||||
|
||||
@@ -11,7 +11,7 @@ typedef enum : uint8_t {
|
||||
INST_XOR, INST_SHF, INST_JMP, INST_JIZ, INST_CALL, INST_RET, INST_PORT, INST_HLT
|
||||
} InstructionOpcode;
|
||||
|
||||
typedef enum {
|
||||
typedef enum : uint8_t {
|
||||
// General purpose registers
|
||||
REG_A, REG_B, REG_C,
|
||||
|
||||
|
||||
@@ -10,16 +10,7 @@ int main() {
|
||||
}
|
||||
|
||||
RomFile* romFile = readProgramFromFile("../test.bin");
|
||||
|
||||
/*Instruction program[] = {
|
||||
{INST_MVI, {REG_A, 0, 0}, 5, true},
|
||||
{INST_MVI, {REG_B, 0, 0}, 3, true},
|
||||
{INST_ADD, {REG_A, REG_B, 0}, 0, false},
|
||||
{INST_HLT, {}, 0, false}
|
||||
};*/
|
||||
printf("%d\n", romFile->header.numInstructions);
|
||||
memoryLoadProgram(emu->mem, romFile->instructions, romFile->header.numInstructions);
|
||||
|
||||
|
||||
//startEmulator(emu);
|
||||
freeEmulator(emu);
|
||||
|
||||
Reference in New Issue
Block a user