summaryrefslogtreecommitdiff
path: root/interpreter.c
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-04-11 13:30:17 +1000
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-04-11 13:30:17 +1000
commit07980e780e331352ea81d0176d9028325968a771 (patch)
tree8364d564b93ca7abbb190a308abaf205bdb04487 /interpreter.c
parent3f3574efb1e1c27d2f471c9b4a87a9786326e773 (diff)
interpreter.c can run, but segfaults.
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);
}
}