summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xa.outbin0 -> 30760 bytes
-rw-r--r--debug.h2
-rw-r--r--instruction-init.h7
-rw-r--r--interpreter.c28
4 files changed, 23 insertions, 14 deletions
diff --git a/a.out b/a.out
new file mode 100755
index 0000000..2a4c22b
--- /dev/null
+++ b/a.out
Binary files differ
diff --git a/debug.h b/debug.h
index 85520ca..0ef38ce 100644
--- a/debug.h
+++ b/debug.h
@@ -21,7 +21,7 @@ int dCharToNum(char c){
// Dump a particular page in memory.
void dPageDump(short m){
- m *= 0x0100;
+ m <<= 8;
for(int i = 0; i < 256; i+=16){
printf("\t");
for(int j = 0; j < 16; j+=1){
diff --git a/instruction-init.h b/instruction-init.h
index 01b3fd8..ccfbc85 100644
--- a/instruction-init.h
+++ b/instruction-init.h
@@ -15,8 +15,13 @@ void setIT(int i, uintptr_t p, Addressing r){
*r1 = r;
}
+uintptr_t getITFunction(int i){
+ Addressing* r = (IT + (sizeof(uintptr_t)*i));
+ return *r;
+}
+
Addressing getITAddressing(int i){
- Addressing* r = IT + (sizeof(uintptr_t)*256)) + (sizeof(Addressing)*i)
+ Addressing* r = (IT + (sizeof(uintptr_t)*256) + (sizeof(Addressing)*i));
return *r;
}
diff --git a/interpreter.c b/interpreter.c
index 766d387..652c181 100644
--- a/interpreter.c
+++ b/interpreter.c
@@ -14,7 +14,7 @@ int main(){
char c;
unsigned char a, b;
while(1){
- c = getchar();
+ c = fgetc(stdin);
// Exit condition
if ( (c == 'Q') || (c == 'q') || (c == EOF) ) break;
@@ -28,29 +28,33 @@ int main(){
break;
// Dump memory page
case 'M': case 'm':
- dPageDump();
+ byte m;
+ m += dCharToNum(fgetc(stdin)) << 4;
+ m += dCharToNum(fgetc(stdin));
+ dPageDump(m);
break;
case ' ':
break;
}
- }else{
- // Run Instruction
+ }else{ // RUN INSTRUCTION
+ // Pass in Instruction
byte inst = dCharToNum(c) << 4;
- inst += dCharToNum(getch());
- address pass = 0;
- int temp = fAddressGetLength(getITAddressing(inst));
- temp *= 2;
- c = getch();
- for(int i = 0; i < temp; i++)
+ inst += dCharToNum(fgetc(stdin));
+ // Pass in Value
+ address pass = 0x0000;
+ int range = fAddressGetLength(getITAddressing(inst));
+ range = ((2*range)-2);
+ c = fgetc(stdin);
+ for(int i = 0; i < range; i++){
if (c != ' ' && c != EOF){
pass <<= 4;
pass += c;
- c = getch();
+ c = fgetc(stdin);
}else{
break;
}
}
- current_instruction = IT[inst];
+ current_instruction = getITFunction(inst);
callIT(current_instruction, pass);
}
}