summaryrefslogtreecommitdiff
path: root/interpreter.c
blob: fece47391d10d2b3240c32c21e30b0aee0e69eff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//  test.c
//  Temporary .c file where arbitrary tests are carried out.

#include"headers/include.h" //LOOK INTO PTHREADS
#include"headers/debug.h"

int main(int argc, char *argv[]){
    AppleOn();
    

    byte c;

    // Interpreter loop
    while(1){
        do {
            c = getc(stdin);
        } while (c == '\n' || c == ' ');

        if (c == 'P' || c == 'p'){
            dStatusDump();
            continue;
        }

        if (c == 'M' || c == 'm'){
            c = dCharToNum(getc(stdin)) << 4;
            c += dCharToNum(getc(stdin));
            dPageDump(c);
            continue;
        }

        //  From here on it is expected input will be mostly correct
        c = dCharToNum(c) << 4;
        c += dCharToNum(getc(stdin));
        address x = 0x0000;
        char z;
        for(int i = ((fAddressGetLengthPrempt(c) * 2) - 2); i > 0; i--) {
            z = getc(stdin);
            if (z != '\n'){
                x += dCharToNum(z) << ((4 * (i - 1)));
            }else{
                i++;
            }
        }
        callInstructionTable(c, x);
    }

}