summaryrefslogtreecommitdiff
path: root/headers/instruction-init.h
diff options
context:
space:
mode:
Diffstat (limited to 'headers/instruction-init.h')
-rw-r--r--headers/instruction-init.h29
1 files changed, 7 insertions, 22 deletions
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);