cleaned up verbosity in vm-dcpu16.c
authorJustin Wind <justin.wind@gmail.com>
Fri, 13 Apr 2012 22:01:43 +0000 (15:01 -0700)
committerJustin Wind <justin.wind@gmail.com>
Fri, 13 Apr 2012 22:01:43 +0000 (15:01 -0700)
vm-dcpu16.c

index df86455070e7c91b008456579eeb2360b0425959..b59c253ee0700fa561a55ddb221650bb9d9f3632 100644 (file)
@@ -61,7 +61,7 @@ void usage_(char *prog, unsigned int full) {
     if (full) {
         fprintf(f, "\nOptions:\n"
                 "\t [file] -- ram image to load initially\n"
-                "\t -v -- verbose execution tracing\n"
+                "\t -v -- displays slightly more information\n"
                 "\t -h -- this screen\n");
 
         fprintf(f, "\n%78s\n", src_id_);
@@ -190,7 +190,7 @@ struct command_ {
 
 COMMAND_IMPL(quit) {
     (void)vm, (void)arg_count, (void)arg_vector;
-    VERBOSE_PRINTF("done\n");
+
     return -1;
 }
 COMMAND_HELP(quit) {
@@ -331,12 +331,11 @@ COMMAND_IMPL(step) {
     }
 
     while (count--) {
-        VERBOSE_PRINTF("executing next cycle, instruction: ");
-        dcpu16_disassemble_print(vm, vm->pc), printf("\n");
-
+        dcpu16_disassemble_print(vm, vm->pc);
+        printf("\n");
         dcpu16_step(vm);
 
-        if (opt_.verbose)
+        if (count > 1 && opt_.verbose)
             dcpu16_state_print(vm);
     }
 
@@ -364,8 +363,12 @@ COMMAND_IMPL(run) {
 
     while(running_) {
         dcpu16_step(vm);
-        if (opt_.verbose)
+        if (opt_.verbose > 1)
             dcpu16_state_print(vm);
+        else if (opt_.verbose) {
+            dcpu16_disassemble_print(vm, vm->pc);
+            printf("\n");
+        }
     }
 
     /* restore the old interrupt signal handler */
@@ -374,7 +377,7 @@ COMMAND_IMPL(run) {
         return -1;
     }
 
-    VERBOSE_PRINTF("interrupted...\n");
+    printf("interrupted...\n");
 
     return 0;
 }
@@ -382,7 +385,8 @@ COMMAND_HELP(run) {
     fprintf(f, "\trun\n");
     if (summary) return;
 
-    fprintf(f, "Begins executing continuously.\n");
+    fprintf(f, "Begins executing continuously.\n"
+               "May be interrupted with SIGINT.\n");
 }
 
 /* gather all these together into a searchable table */
@@ -428,7 +432,7 @@ COMMAND_HELP(help) {
         fprintf(f, "\thelp [command]\n");
         if (summary) return;
 
-    fprintf(f, "Displays a list of available commands, or help on a specific command.\n");
+    fprintf(f, "Displays a list of available commands, or detailed help on a specific command.\n");
 }
 
 
@@ -466,7 +470,7 @@ int main(int argc, char **argv) {
     argv += optind;
 
     if ((vm = dcpu16_new()) == NULL) {
-        fprintf(stderr, "could not allocate new dcpu instance\n");
+        fprintf(stderr, "could not allocate new dcpu16 instance\n");
         exit(EX_UNAVAILABLE);
     }