-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdp8.c
49 lines (40 loc) · 792 Bytes
/
sdp8.c
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
#include <stdio.h>
#include <stdlib.h>
#include "sdp8.h"
#include "sim.h"
#include "memory.h"
#include "readtape.h"
/* --- main ---------------------------------------------------------- */
void dump_state(void)
{
printf("%04o: ir=%04o acc=%04o link=%1o\n", pc, ir, acc, link);
}
static void sim_loop()
{
halt = 0;
acc = 0;
do {
ir = mem_read(pc);
dump_state();
pc++;
do_instruction();
pc &= 07777;
} while (!halt);
dump_state();
}
int main(int argc, char *argv[])
{
if (argc<2) {
printf("usage: %s filename [startadr]\n", argv[0]);
return 1;
}
read_tape(argv[1]);
// determine the start address
pc = 0;
if (argc>2) {
pc = strtol(argv[2], NULL, 0) & 07777;
}
// simulate the program
printf("Start the emulation at address 0%04o\n", pc);
sim_loop();
}