YACASL2
dump.c
Go to the documentation of this file.
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 
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);
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 }
#define FREE(ptr)
メモリを解放するマクロ
Definition: cmem.h:21
void dumpmemory(WORD start, WORD end)
COMET IIのメモリを表示する
Definition: dump.c:4
void dspregister()
COMET IIのレジスタを表示する
Definition: dump.c:38
@ GRSIZE
Definition: struct.h:18
SYSTEM * sys
COMET IIの仮想実行マシンシステム
Definition: struct.c:7
EXECMODE execmode
実行モード: trace, logical, dump, monitor, step
Definition: exec.c:91
WORD gr[GRSIZE]
Definition: struct.h:36
WORD sp
Definition: struct.h:37
WORD fr
Definition: struct.h:39
WORD pr
Definition: struct.h:38
bool logical
Definition: struct.h:143
int memsize
Definition: struct.h:48
WORD * memory
Definition: struct.h:47
CPU * cpu
Definition: struct.h:46
unsigned short WORD
16ビットの数値を表すデータ型
Definition: word.h:9
void print_dumpword(WORD word, bool logicalmode)
WORD値を解析して表示する
Definition: word.c:137
char * word2bit(const WORD word)
WORD値を2進数の文字列に変換する
Definition: word.c:120