YACASL2
struct.h
Go to the documentation of this file.
1 #ifndef YACASL2_STRUCT_INCLUDED
2 #define YACASL2_STRUCT_INCLUDED
3 
4 #include <stdio.h>
5 #include <assert.h>
6 #include <string.h>
7 #include <time.h>
8 #include "word.h"
9 #include "cmem.h"
10 #include "hash.h"
11 #include "exec.h"
12 
16 enum {
17  CMDSIZE = 4,
18  GRSIZE = 8,
20  DEFAULT_CLOCKS = 5000000,
21 };
22 
26 enum {
27  OF = 0x4,
28  SF = 0x2,
29  ZF = 0x1,
30 };
31 
35 typedef struct {
36  WORD gr[GRSIZE];
37  WORD sp;
38  WORD pr;
39  WORD fr;
40 } CPU;
41 
45 typedef struct {
46  CPU *cpu;
48  int memsize;
49  clock_t clocks;
50 } SYSTEM;
51 
55 extern SYSTEM *sys;
56 
60 typedef enum {
64 } CMDTAB_HASH;
65 
70 typedef enum {
77  R_ADR_X = 01,
83  R1_R2 = 02,
89  ADR_X = 03,
94  R_ = 04,
98  NONE = 0,
99 } CMDTYPE;
100 
104 typedef struct {
105  char *name;
106  const void (*ptr);
107 } CMD;
108 
112 typedef struct {
113  char *name;
116  const void (*ptr);
117 } COMET2CMD;
118 
122 typedef struct _CMDTAB {
123  struct _CMDTAB *next;
124  const COMET2CMD *cmd;
126 
130 typedef struct {
133  bool stop;
134 } EXECPTR;
135 
136 extern EXECPTR *execptr;
137 
141 typedef struct {
142  bool trace;
143  bool logical;
144  bool dump;
146  int dump_end;
147  bool monitor;
148  bool step;
149 } EXECMODE;
150 
154 extern EXECMODE execmode;
155 
163 char *grstr(WORD word);
164 
168 void reset(int memsize, int clocks);
169 
173 void shutdown();
174 
183 
188 
193 WORD getcmdcode(const char *cmd, CMDTYPE type);
194 
198 const void (*getcmdptr(WORD code));
199 
203 CMDTYPE getcmdtype(WORD code);
204 
208 char *getcmdname(WORD code);
209 
210 #endif
unsigned hash(int keyc, HKEY *keyv[], int tabsize)
ハッシュ値を取得する
Definition: hash.c:3
@ DEFAULT_MEMSIZE
Definition: struct.h:19
@ DEFAULT_CLOCKS
Definition: struct.h:20
@ CMDSIZE
Definition: struct.h:17
@ GRSIZE
Definition: struct.h:18
CMDTAB_HASH
Definition: struct.h:60
@ HASH_CMDTYPE
Definition: struct.h:61
@ HASH_MAX
Definition: struct.h:63
@ HASH_CODE
Definition: struct.h:62
void reset(int memsize, int clocks)
Definition: struct.c:253
char * getcmdname(WORD code)
Definition: struct.c:222
CMDTYPE getcmdtype(WORD code)
Definition: struct.c:205
EXECPTR * execptr
Definition: struct.c:12
bool create_cmdtable(CMDTAB_HASH hash)
命令ハッシュ表を作成する
Definition: struct.c:113
void shutdown()
Definition: struct.c:278
CMDTYPE
Definition: struct.h:70
@ R_
Definition: struct.h:94
@ R_ADR_X
Definition: struct.h:77
@ ADR_X
Definition: struct.h:89
@ NONE
Definition: struct.h:98
@ R1_R2
Definition: struct.h:83
void free_cmdtable(CMDTAB_HASH hash)
Definition: struct.c:135
SYSTEM * sys
COMET IIの仮想実行マシンシステム
Definition: struct.c:7
struct _CMDTAB CMDTAB
@ OF
Definition: struct.h:27
@ ZF
Definition: struct.h:29
@ SF
Definition: struct.h:28
const void * getcmdptr(WORD code)
Definition: struct.c:188
char * grstr(WORD word)
汎用レジスタの番号からレジスタを表す文字列を返す
Definition: struct.c:240
WORD getcmdcode(const char *cmd, CMDTYPE type)
Definition: struct.c:153
EXECMODE execmode
実行モード: trace, logical, dump, monitor, step
Definition: exec.c:91
const COMET2CMD * cmd
Definition: struct.h:124
struct _CMDTAB * next
Definition: struct.h:123
Definition: struct.h:104
char * name
Definition: struct.h:105
CMDTYPE type
Definition: struct.h:114
char * name
Definition: struct.h:113
WORD code
Definition: struct.h:115
COMET IIのCPUを表すデータ型
Definition: struct.h:35
WORD sp
Definition: struct.h:37
WORD fr
Definition: struct.h:39
WORD pr
Definition: struct.h:38
実行モードを表すデータ型
Definition: struct.h:141
bool step
Definition: struct.h:148
bool dump
Definition: struct.h:144
bool trace
Definition: struct.h:142
bool logical
Definition: struct.h:143
int dump_start
Definition: struct.h:145
int dump_end
Definition: struct.h:146
bool monitor
Definition: struct.h:147
WORD start
Definition: struct.h:131
WORD end
Definition: struct.h:132
bool stop
Definition: struct.h:133
COMET IIの仮想実行マシンシステムを表すデータ型
Definition: struct.h:45
int memsize
Definition: struct.h:48
clock_t clocks
Definition: struct.h:49
WORD * memory
Definition: struct.h:47
CPU * cpu
Definition: struct.h:46
unsigned short WORD
16ビットの数値を表すデータ型
Definition: word.h:9