Improve parsing possibility of program output
This commit is contained in:
parent
306b35f451
commit
6613661ce4
@ -1,7 +1,7 @@
|
|||||||
# Koopman TOY CPU Interpreter
|
# Koopman TOY CPU Interpreter
|
||||||
|
|
||||||
This is a CPU interpreter, based on the specification of Phil Koopmans paper: [Microcoded Versus Hard-wired Control](https://users.ece.cmu.edu/~koopman/misc/byte87a.pdf).<br>
|
This is a CPU interpreter, based on the specification of Phil Koopmans paper: [Microcoded Versus Hard-wired Control](https://users.ece.cmu.edu/~koopman/misc/byte87a.pdf).<br>
|
||||||
For more details, have a look at /doc or press `toy_cpu -h` (for help) or `toy_cpu -i` (for cpu architecture overview)
|
For more details, have a look at /doc or press `toy_cpu -h` (for help) or `toy_cpu -a` (for cpu architecture overview)
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -28,9 +28,6 @@ int main(int argc, char *argv[])
|
|||||||
if(initialise_ram(ram,argc,argv)==-1) return 1; /*load data from command line into RAM
|
if(initialise_ram(ram,argc,argv)==-1) return 1; /*load data from command line into RAM
|
||||||
(-1 in case of error,
|
(-1 in case of error,
|
||||||
else number of correctly read words)*/
|
else number of correctly read words)*/
|
||||||
|
|
||||||
print_architecture(); //print cpu architecture at startup
|
|
||||||
|
|
||||||
while(run)
|
while(run)
|
||||||
{
|
{
|
||||||
ir = ram[pc]; //get instruction from RAM
|
ir = ram[pc]; //get instruction from RAM
|
||||||
@ -57,8 +54,8 @@ int main(int argc, char *argv[])
|
|||||||
//handle user output
|
//handle user output
|
||||||
printf("ACCU: %d\n",get2compl(*ACCU));
|
printf("ACCU: %d\n",get2compl(*ACCU));
|
||||||
printf("PROGRAM COUNTER: %" PRIu16
|
printf("PROGRAM COUNTER: %" PRIu16
|
||||||
"\n-----------------------------------",pc);
|
"\n----------------------------------------",pc);
|
||||||
printf("\n(n)ext step or (q)uit or (c)oredump ?\n");
|
printf("\n|(n)ext step or (q)uit or (c)oredump ? ");
|
||||||
|
|
||||||
//handle program flow
|
//handle program flow
|
||||||
while((quit = getchar()) != '\n')
|
while((quit = getchar()) != '\n')
|
||||||
@ -70,6 +67,8 @@ int main(int argc, char *argv[])
|
|||||||
case 'q': run = false;
|
case 'q': run = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("----------------------------------------\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,9 @@ int initialise_ram(uint16_t *ram, int argc, char **argv )
|
|||||||
if(argc<2)
|
if(argc<2)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s","no \".toy\" input file!\n"
|
fprintf(stderr,"%s","no \".toy\" input file!\n"
|
||||||
"interpretation terminated. (press -h for help)\n");
|
"interpretation terminated.\n\n"
|
||||||
|
"press toy-CPU -h for help\n"
|
||||||
|
"press toy-CPU -a for cpu architecture overview\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(argc >2)
|
if(argc >2)
|
||||||
@ -128,7 +130,7 @@ int initialise_ram(uint16_t *ram, int argc, char **argv )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strcmp(argv[1],"-i")==0)
|
if(strcmp(argv[1],"-a")==0)
|
||||||
{
|
{
|
||||||
printf("interpretation terminated.\n\n");
|
printf("interpretation terminated.\n\n");
|
||||||
print_architecture();
|
print_architecture();
|
||||||
|
Loading…
Reference in New Issue
Block a user