Compare commits
2 Commits
afa45ea82d
...
c0da7748d2
| Author | SHA1 | Date | |
|---|---|---|---|
| c0da7748d2 | |||
| 14700bdf59 |
@@ -24,6 +24,8 @@ int main(int argc, char** argv) {
|
|||||||
{INST_HLT, {}, 0, false}
|
{INST_HLT, {}, 0, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RomFile* f = readProgramFromFile("../add.o");
|
||||||
|
memcpy(emu->mem + MEM_PROGRAM_START, f->instructions, sizeof(SerializedInst) * f->header.numInstructions);
|
||||||
memoryLoadProgram(emu->mem, program, sizeof(program)/sizeof(program[0]));
|
memoryLoadProgram(emu->mem, program, sizeof(program)/sizeof(program[0]));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -33,7 +35,7 @@ int main(int argc, char** argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memoryLoadProgram(emu->mem, rom->instructions, rom->header.numInstructions);
|
memcpy(emu->mem + MEM_PROGRAM_START, rom->instructions, sizeof(SerializedInst) * rom->header.numInstructions);
|
||||||
|
|
||||||
startEmulator(emu);
|
startEmulator(emu);
|
||||||
freeEmulator(emu);
|
freeEmulator(emu);
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ uint32_t memorySerializeInst(Memory* m, Instruction inst, uint32_t offset) {
|
|||||||
void memoryLoadProgram(Memory* m, Instruction program[], size_t numInstructions) {
|
void memoryLoadProgram(Memory* m, Instruction program[], size_t numInstructions) {
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
for (size_t i = 0; i < numInstructions; i++) {
|
for (size_t i = 0; i < numInstructions; i++) {
|
||||||
|
printf("%zu. %s\n", i, instructionToCStr(program[i]));
|
||||||
offset = memorySerializeInst(m, program[i], offset);
|
offset = memorySerializeInst(m, program[i], offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ RomFile* readProgramFromFile(char* path) {
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
ROMFileHeader* header = (ROMFileHeader*)buffer;
|
ROMFileHeader* header = (ROMFileHeader*)buffer;
|
||||||
Instruction* instructions = calloc(header->numInstructions, sizeof(SerializedInst));
|
SerializedInst* instructions = calloc(header->numInstructions, sizeof(SerializedInst));
|
||||||
if (!instructions) {
|
if (!instructions) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ROMFileHeader header;
|
ROMFileHeader header;
|
||||||
Instruction* instructions;
|
SerializedInst* instructions;
|
||||||
} RomFile;
|
} RomFile;
|
||||||
|
|
||||||
// -- FUNCTIONS -- //
|
// -- FUNCTIONS -- //
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
dingus:
|
|
||||||
|
|
||||||
mvi a 2
|
mvi a 2
|
||||||
mvi b 2
|
mvi b 2
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user