summaryrefslogtreecommitdiff
path: root/interpreter.c
diff options
context:
space:
mode:
Diffstat (limited to 'interpreter.c')
-rw-r--r--interpreter.c28
1 files changed, 16 insertions, 12 deletions
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);
}
}