blob: 766d387fd6fd950cfc03a4a8f543481b7e8e030a (
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
48
49
50
51
52
53
54
55
56
57
58
|
/*
* interpreter.c WILL BE a tool which can be used to interpret 6502 machine code inline.
* Machine code is expected as hexadecimal of length 2 or 6, depending on the instruction.
* There are a few special characters which print debug information
Q - Quit
P - Processor status dump
M - Dump a page of memory
*/
#include"include.h"
#include"debug.h"
int main(){
char c;
unsigned char a, b;
while(1){
c = getchar();
// Exit condition
if ( (c == 'Q') || (c == 'q') || (c == EOF) ) break;
if (dCharToNum(c) == -1){
// Debug print conditions
switch(c){
// Print debug information
case 'P': case 'p':
dStatusDump();
break;
// Dump memory page
case 'M': case 'm':
dPageDump();
break;
case ' ':
break;
}
}else{
// Run 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++)
if (c != ' ' && c != EOF){
pass <<= 4;
pass += c;
c = getch();
}else{
break;
}
}
current_instruction = IT[inst];
callIT(current_instruction, pass);
}
}
return 0;
}
|