X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Fstruct.c;h=1fb4326d176e1263c8de7e5f8dd45fca905df721;hp=f21c92e099a3b8ec00424c07d4fd6d7709d82e5d;hb=f9e27534c723ae199ed32404047b9a2c6519a8a9;hpb=54b6bf4b0ce20872db02bae2f047c6574c09575c diff --git a/src/struct.c b/src/struct.c index f21c92e..1fb4326 100644 --- a/src/struct.c +++ b/src/struct.c @@ -3,31 +3,42 @@ /* COMET IIのメモリ */ WORD *memory; -/* COMET IIのCPUレジスタ */ -WORD GR[REGSIZE], SP, PR, FR; - -/* メモリーサイズ */ +/* メモリサイズ */ int memsize = DEFAULT_MEMSIZE; +/* COMET IIのCPU */ +CPU *cpu; + /* クロック周波数 */ int clocks = DEFAULT_CLOCKS; -/* 実行開始番地 */ -WORD startptr = 0x0; - -/* 実行終了番地 */ -WORD endptr = 0x0; +/* CASL2プログラムのプロパティ */ +PROGPROP *progprop; /* COMET II仮想マシンのリセット */ void reset() { int i; - for(i = 0; i < REGSIZE; i++) { - GR[i] = 0x0; - } - SP = PR = FR = 0x0; - memory = malloc(memsize * sizeof(WORD)); + + /* メモリの初期化 */ + memory = malloc_chk(memsize * sizeof(WORD), "memory"); for(i = 0; i < memsize; i++) { memory[i] = 0x0; } + /* CPUの初期化 */ + cpu = malloc_chk(sizeof(CPU), "cpu"); + for(i = 0; i < GRSIZE; i++) { + cpu->gr[i] = 0x0; + } + cpu->sp = cpu->pr = cpu->fr = 0x0; + /* CASL2プログラムのプロパティ */ + progprop = malloc_chk(sizeof(PROGPROP), "progprop"); +} + +/* COMET II仮想マシンのシャットダウン */ +void shutdown() +{ + free(progprop); + free(cpu); + free(memory); }