summaryrefslogtreecommitdiff
path: root/instruction-init.h
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-04-20 12:51:50 +1000
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-04-20 12:51:50 +1000
commitc138759ebf4194a73364a79a9acc87f54dcc73bc (patch)
treebe113336c04e39954863a55e8a39e7c46a404f4e /instruction-init.h
parent10fedb851f6654874a644f4b158a4d9d404da14e (diff)
callIT() FINALLY WORKS
Diffstat (limited to 'instruction-init.h')
-rw-r--r--instruction-init.h22
1 files changed, 13 insertions, 9 deletions
diff --git a/instruction-init.h b/instruction-init.h
index c2f85ed..adb5047 100644
--- a/instruction-init.h
+++ b/instruction-init.h
@@ -4,17 +4,19 @@
//InstructionTable
void* IT;
-
-
+void (*func)(Addressing, address);
void setIT(int i, uintptr_t p, Addressing r){
- uintptr_t* p1 = (IT + (i * sizeof(uintptr_t)));
+ uintptr_t* p1 = (IT + (sizeof(uintptr_t)*i));
*p1 = p;
- Addressing* r1 = (IT + ((sizeof(uintptr_t)*256)) + (i * sizeof(Addressing)));
+ Addressing* r1 = (IT + (sizeof(uintptr_t)*256) + (sizeof(Addressing)*i));
*r1 = r;
+
+ printf("DEBUG:\t%x\t%x -> %x\t%x -> %x\n", i, p1, *p1, r1, *r1);
}
+/*
uintptr_t getITFunction(int i){ //Segmentation fault is occurring here, likely in next one too
uintptr_t r = (IT + (sizeof(uintptr_t)*i));
return r;
@@ -24,13 +26,14 @@ Addressing getITAddressing(int i){
Addressing r = (IT + (sizeof(uintptr_t)*256) + (sizeof(Addressing)*i));
return r;
}
+*/
void callIT(int i, address val){
- void (*func)(Addressing, address);
- func = (IT + (sizeof(uintptr_t) * i));
- Addressing r = (IT + ((i * sizeof(Addressing)) + (sizeof(uintptr_t)*256)));
- func(r, val);
+ uintptr_t a = ((uintptr_t)IT + (sizeof(uintptr_t) * i));
+ memcpy(&func, a, sizeof(uintptr_t));
+ Addressing* r = (IT + ((sizeof(uintptr_t)*256) + (sizeof(Addressing) * i)));
+ func(*r, val);
}
@@ -104,7 +107,8 @@ void fSEI(Addressing, address);
void fNOP(Addressing, address);
void fBRK(Addressing, address);
-void initIT(){
+void initIT(){ //Change this to load a binary file which contains this same information.
+ //So will need to dump the contents of IT at some point.
IT = malloc(256 * (sizeof(uintptr_t) + sizeof(Addressing)));
// Load and Store Instructions