X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Fstruct.c;h=1f62a134889820a9a15f1638e52c2578b2e9b997;hp=7c3e785800b5cf291b8c17bc0543ef1741bb73d5;hb=4ee27a568fb9222907a566e59aaefe248f08a8e4;hpb=5562b8293058464957a1f833777e187a78220ed5 diff --git a/src/struct.c b/src/struct.c index 7c3e785..1f62a13 100644 --- a/src/struct.c +++ b/src/struct.c @@ -3,37 +3,40 @@ /* 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(cpu); free(memory); }