X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Fstruct.c;h=1fb4326d176e1263c8de7e5f8dd45fca905df721;hp=89daa0587a59d59993d3f039d9b57ec1901b18f4;hb=650f92bf8dfdd0095db993f71f9e3867e7119acc;hpb=ccc3acda4256e10a822e41e84f6c9991271c2f61 diff --git a/src/struct.c b/src/struct.c index 89daa05..1fb4326 100644 --- a/src/struct.c +++ b/src/struct.c @@ -3,17 +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; +/* CASL2プログラムのプロパティ */ +PROGPROP *progprop; + +/* COMET II仮想マシンのリセット */ +void reset() +{ + int i; + + /* メモリの初期化 */ + 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"); +} -/* 実行終了番地 */ -WORD endptr = 0x0; +/* COMET II仮想マシンのシャットダウン */ +void shutdown() +{ + free(progprop); + free(cpu); + free(memory); +}