Improve parsing possibility of program output

This commit is contained in:
lux 2018-02-04 14:39:42 +01:00
parent 306b35f451
commit 6613661ce4
3 changed files with 15 additions and 14 deletions

View File

@ -1,7 +1,7 @@
# 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>
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

View File

@ -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
(-1 in case of error,
else number of correctly read words)*/
print_architecture(); //print cpu architecture at startup
while(run)
{
ir = ram[pc]; //get instruction from RAM
@ -57,19 +54,21 @@ int main(int argc, char *argv[])
//handle user output
printf("ACCU: %d\n",get2compl(*ACCU));
printf("PROGRAM COUNTER: %" PRIu16
"\n-----------------------------------",pc);
printf("\n(n)ext step or (q)uit or (c)oredump ?\n");
"\n----------------------------------------",pc);
printf("\n|(n)ext step or (q)uit or (c)oredump ? ");
//handle program flow
while((quit = getchar()) != '\n')
{
switch(quit)
{
case EOF: break;
case 'c': makeHexDump(true,ram); break;
case 'q': run = false;
}
switch(quit)
{
case EOF: break;
case 'c': makeHexDump(true,ram); break;
case 'q': run = false;
}
}
printf("----------------------------------------\n");
}
return 0;
}

View File

@ -113,7 +113,9 @@ int initialise_ram(uint16_t *ram, int argc, char **argv )
if(argc<2)
{
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;
}
if(argc >2)
@ -128,7 +130,7 @@ int initialise_ram(uint16_t *ram, int argc, char **argv )
return -1;
}
if(strcmp(argv[1],"-i")==0)
if(strcmp(argv[1],"-a")==0)
{
printf("interpretation terminated.\n\n");
print_architecture();