From ae800796cdcce21c561bcbfbc96b29efe4d39a0b Mon Sep 17 00:00:00 2001 From: alekseiplusplus Date: Fri, 21 Apr 2023 10:21:14 +1000 Subject: used a file to hold dynamic addresses :/ works now --- headers/instruction-init.h | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'headers/instruction-init.h') diff --git a/headers/instruction-init.h b/headers/instruction-init.h index 488f73c..68b9cf3 100644 --- a/headers/instruction-init.h +++ b/headers/instruction-init.h @@ -8,41 +8,26 @@ void (*func)(Addressing, address); #define InstructionTableSize (256 * (sizeof(uintptr_t) + sizeof(Addressing))) -/* -uintptr_t getInstructionTableFunction(int i){ //Segmentation fault is occurring here, likely in next one too - uintptr_t r = (InstructionTable + (sizeof(uintptr_t)*i)); +uintptr_t* getInstructionTableFunction(int i){ //Segmentation fault is occurring here, likely in next one too + uintptr_t* r = (InstructionTable + (sizeof(uintptr_t)*i)); return r; } -Addressing getInstructionTableAddressing(int i){ - Addressing r = (InstructionTable + (sizeof(uintptr_t)*256) + (sizeof(Addressing)*i)); +Addressing* getInstructionTableAddressing(int i){ + Addressing* r = (InstructionTable + (sizeof(uintptr_t)*256) + (sizeof(Addressing)*i)); return r; } -*/ void callInstructionTable(int i, address val){ printf("Table:\t%x\n", InstructionTable); - uintptr_t* a = (InstructionTable + (sizeof(uintptr_t) * i)); + uintptr_t a = getInstructionTableFunction(i); printf("A Val:\t%x\n", a); - printf("Before:\t%x\n", func); func = *a; printf("After:\t%x\n", func); - //printf("Before:\t%x\n", func); memcpy(&func, a, sizeof(uintptr_t)); printf("After:\t%x\n", func); + //printf("Before:\t%x\n", func); func = a; printf("After:\t%x\n", func); + printf("Before:\t%x\n", func); memcpy(&func, a, sizeof(uintptr_t)); printf("After:\t%x\n", func); Addressing* r = (InstructionTable + ((sizeof(uintptr_t)*256) + (sizeof(Addressing) * i))); func(*r, val); printf("Statement OK"); } -void initInstructionTable(){ - InstructionTable = malloc(InstructionTableSize); - FILE* fs = fopen("instructions.bin", "r"); - - for(byte* c = InstructionTable; c < (InstructionTable + InstructionTableSize); c++){ //NEED TO MAKE (InstructionTable + (256*(sizeof(uintptr_t) + sizeof(Addressing)))) a macro - *c = (byte)fgetc(fs); - } //Investigate whether doing word sized units would increase speed - fclose(fs); - //read in the instruction data binary -} - - - // Load and Store Instructions void fLDA(Addressing, address); void fLDX(Addressing, address); -- cgit v1.2.3