root/src/dump.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. dumpmemory
  2. dspregister

   1 #include "exec.h"
   2 
   3 /* exec.hに定義された関数群 */
   4 void dumpmemory(WORD start, WORD end)
   5 {
   6     const WORD col = 0x10;
   7     WORD mod = 0;
   8     /* Header */
   9     fprintf(stdout, "#%04X: adr :", sys->cpu->pr);
  10     if(end > sys->memsize) {
  11         end = sys->memsize;
  12     }
  13     for(int i = 0; i < sys->memsize && i < col; i++) {
  14         fprintf(stdout, " %04X", i);
  15     }
  16     fprintf(stdout, "\n");
  17     fprintf(stdout, "       -------------------------------------------------------------------------------------\n");
  18     /* Memory */
  19     for(int i = start; i < end; i++) {
  20         mod = i % col;
  21         if(mod == 0 || i == start) {
  22             fprintf(stdout, "#%04X: %04X: ", sys->cpu->pr, i);
  23         }
  24         if(i == start) {
  25             for(int j = 0; j < mod; j++) {
  26                 fprintf(stdout, "     ");
  27             }
  28         }
  29         fprintf(stdout, "%04X", sys->memory[i]);
  30         if((i > 0 && (i + 1) % col == 0) || (i + 1) == end) {
  31             fprintf(stdout, "\n");
  32         } else {
  33             fprintf(stdout, " ");
  34         }
  35     }
  36 }
  37 
  38 void dspregister()
  39 {
  40     char *sp = word2bit(sys->cpu->sp);
  41     char *pr = word2bit(sys->cpu->pr);
  42     char *fr = word2bit(sys->cpu->fr);
  43     enum {
  44         L3BIT = 16 - 3,     /* WORD値16ビットのうち、下位3ビットの開始位置 */
  45     };
  46     for(int i = 0; i < GRSIZE; i++ ) {
  47         fprintf(stdout, "#%04X: GR%d: ", sys->cpu->pr, i);
  48         print_dumpword(sys->cpu->gr[i], execmode.logical);
  49         fprintf(stdout, "\n");
  50     }
  51     fprintf(stdout, "#%04X: SP:  %6d = #%04X = %s\n", sys->cpu->pr, sys->cpu->sp, sys->cpu->sp, sp);
  52     fprintf(stdout, "#%04X: PR:  %6d = #%04X = %s\n", sys->cpu->pr, sys->cpu->pr, sys->cpu->pr, pr);
  53     fprintf(stdout, "#%04X: FR (OF SF ZF): %s\n", sys->cpu->pr, fr + L3BIT); /* FRは下位3けたを表示 */
  54     FREE(sp);
  55     FREE(pr);
  56     FREE(fr);
  57 }

/* [<][>][^][v][top][bottom][index][help] */