Files
MyLittleCPU/src/memory.h
2026-07-15 15:54:51 +10:00

23 lines
589 B
C

#pragma once
#include <stdint.h>
#include <stdlib.h>
#include "instruction.h"
#define MEM_CALL_STACK_OFFSET 0x00000FFF
#define MEM_PROGRAM_START 0x00001000
#define MEM_PROGRAM_END 0x0000FFFF
#define MEM_GP_START 0x00010000
// -- TYPES -- //
typedef struct {
uint32_t size;
uint8_t* data;
} Memory;
// -- FUNCTIONS -- //
Memory* initMemory(uint32_t size);
void freeMemory(Memory* m);
uint16_t memoryLoadWord(Memory* m, uint32_t address);
void memorySaveWord(Memory* m, uint32_t address, uint16_t value);
Instruction decodeInstruction(Memory* m, uint32_t* pc);