summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--headers/include.h3
-rw-r--r--headers/instruction-bin.h (renamed from instruction-bin.c)20
-rw-r--r--headers/instruction-init.h29
-rwxr-xr-xinbinbin0 -> 30760 bytes
-rw-r--r--makefile2
-rw-r--r--test.c21
7 files changed, 20 insertions, 56 deletions
diff --git a/.gitignore b/.gitignore
index 9656d78..8da0d65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ main
instructions.bin
instruction-dump
.vscode/settings.json
+a
diff --git a/headers/include.h b/headers/include.h
index 9a537c4..e2578de 100644
--- a/headers/include.h
+++ b/headers/include.h
@@ -4,4 +4,5 @@
#include"string.h"
#include"applesystem.h"
#include"addressing.h"
-#include"instructions.h" \ No newline at end of file
+#include"instructions.h"
+#include"instruction-bin.h" \ No newline at end of file
diff --git a/instruction-bin.c b/headers/instruction-bin.h
index 074a1e4..0127fd7 100644
--- a/instruction-bin.c
+++ b/headers/instruction-bin.h
@@ -1,19 +1,3 @@
-#include"headers/include.h"
-
-void setInstructionTable(int i, uintptr_t p, Addressing r);
-
-void setAllInstructionTable();
-
-int main(){
- setAllInstructionTable();
- // here, do calls to dump all instructions into a bin file
- FILE* fs = fopen("instructions.bin", "w");
- for(char* c = InstructionTable; c < (InstructionTable + InstructionTableSize); c++){
- fputc(*c, fs);
- }
- fclose(fs);
-}
-
void setInstructionTable(int i, uintptr_t p, Addressing r){
uintptr_t* p1 = (InstructionTable + (sizeof(uintptr_t)*i));
*p1 = p;
@@ -22,8 +6,8 @@ void setInstructionTable(int i, uintptr_t p, Addressing r){
*r1 = r;
}
-void setAllInstructionTable(){
- InstructionTable = malloc(256 * (sizeof(uintptr_t) + sizeof(Addressing)));
+void initInstructionTable(){
+ InstructionTable = malloc(InstructionTableSize);
// Load and Store Instructions
// fLDA(Addressing, address);
setInstructionTable(0xA9, (uintptr_t)&fLDA, eImmediate);
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);
diff --git a/inbin b/inbin
new file mode 100755
index 0000000..a6286dd
--- /dev/null
+++ b/inbin
Binary files differ
diff --git a/makefile b/makefile
index 636b454..b4327df 100644
--- a/makefile
+++ b/makefile
@@ -1,2 +1,2 @@
main:
- gcc test.c -o main \ No newline at end of file
+ gcc test.c -o a
diff --git a/test.c b/test.c
index 7da793c..2ced76c 100644
--- a/test.c
+++ b/test.c
@@ -4,21 +4,14 @@
int main(int argc, char *argv[]){
initInstructionTable();
- uintptr_t* a;
- Addressing* b;
- for(int i = 0; i < 256; i++){
- a = InstructionTable + (i * sizeof(uintptr_t));
- printf("\t%x", *a); if(*a < 0x10) printf("\t");
- if ((i % 4) == 3) printf("\n");
+ byte* a;
+ for(int i = 0; i < InstructionTableSize; i++){
+ a = InstructionTable + i;
+ printf("%x\t", *a);
+ if ((i % 8) == 7) printf("\n");
}
- for(int i = 0; i < 256; i++){
- b = InstructionTable + (256 * sizeof(uintptr_t)) + (i * sizeof(Addressing));
- printf("\t%x", *b); if(*b < 0x10) printf("\t");
- if ((i % 4) == 3) printf("\n");
- }
- printf("\n");
- dStatusDump(); dIdataDump(); printf("\n");
- callInstructionTable(0x00, 0x01);
+ printf("\n"); dStatusDump(); dIdataDump(); printf("%x\n", &fLDA); printf("\n");
+ callInstructionTable(0xA9, 0x01);
dStatusDump(); dIdataDump(); printf("\n");
} \ No newline at end of file