summaryrefslogtreecommitdiff
path: root/headers/instruction-init.h
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-04-21 10:21:14 +1000
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-04-21 10:21:14 +1000
commitae800796cdcce21c561bcbfbc96b29efe4d39a0b (patch)
treebbf91b3a4c4d2bd7fd99eb4c65181c6ae8abe442 /headers/instruction-init.h
parentee742e6020248f9695cc9ce5bbace5f42814383e (diff)
used a file to hold dynamic addresses :/ works now
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);