diff options
-rwxr-xr-x | a.out | bin | 30760 -> 30664 bytes | |||
-rw-r--r-- | include.h | 1 | ||||
-rw-r--r-- | instruction-init.h | 22 | ||||
-rw-r--r-- | interpreter.c | 3 | ||||
-rw-r--r-- | test.c | 28 |
5 files changed, 39 insertions, 15 deletions
Binary files differ @@ -1,6 +1,7 @@ #include"stdio.h" #include"stdint.h" #include"stdlib.h" +#include"string.h" #include"applesystem.h" #include"addressing.h" #include"instruction.h"
\ No newline at end of file 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 diff --git a/interpreter.c b/interpreter.c index 4598d2f..6fea22e 100644 --- a/interpreter.c +++ b/interpreter.c @@ -13,6 +13,9 @@ int main(){ char c; unsigned char a, b; + + initIT(); + while(1){ c = fgetc(stdin); @@ -2,10 +2,26 @@ #include"debug.h" int main(){ - fAddressGetLength(eAbsolute); - printf("fAddressGetLength Success\n"); - getITFunction(0x00); - printf("getITFunction Success\n"); - getITAddressing(0x00); - printf("getITAddressing Success\n"); + char c; + unsigned char a, b; + + initIT(); + + //void (*func)(Addressing, address); printf("Statement OK"); + + printf("\n\n"); + + func = &fLDA; + + dStatusDump(); + + //func(*(IT + ((sizeof(uintptr_t)*256)) + (0xA9 * sizeof(Addressing))), *(IT + ((sizeof(uintptr_t)*0xA9)))); + + callIT(0xA9, 0x01); + + dStatusDump(); + + printf("%x\n", (IT + 31)); + + return 0; }
\ No newline at end of file |