diff --git a/emul_inst_exec.c b/emul_inst_exec.c index 4c55829..c055ea0 100644 --- a/emul_inst_exec.c +++ b/emul_inst_exec.c @@ -11,10 +11,12 @@ /* オペコード解読処理群 - START */ void emul_inst_exec_add(int r0, int r1, int r2) { + emul_reg_set(r0, emul_reg_get(r1) + emul_reg_get(r2)); printf("Execute: add r0[%d], r1[%d], r2[%d];\n", r0, r1, r2); } void emul_inst_exec_sub(int r0, int r1, int r2) { + emul_reg_set(r0, emul_reg_get(r1) - emul_reg_get(r2)); printf("Execute: sub r0[%d], r1[%d], r2[%d];\n", r0, r1, r2); } /* オペコード解読処理群 - END */ diff --git a/emul_inst_exec.h b/emul_inst_exec.h index b9acf03..c5ed8e9 100644 --- a/emul_inst_exec.h +++ b/emul_inst_exec.h @@ -2,6 +2,7 @@ #define EMUL_INST_EXEC__ #include "emul_inst_decipher.h" +#include "emul_reg.h" int emul_inst_exec_loadfile(char*); void emul_inst_exec_closefile(); diff --git a/emul_mem.c b/emul_mem.c index fb1d4c2..ed3f33f 100644 --- a/emul_mem.c +++ b/emul_mem.c @@ -1 +1,4 @@ #include "emul_mem.h" + +char mem[EMUL_MEMSIZE]; + diff --git a/emul_mem.h b/emul_mem.h index 8c2a1cf..5e34d52 100644 --- a/emul_mem.h +++ b/emul_mem.h @@ -3,6 +3,6 @@ #define EMUL_MEMSIZE 1024 -char mem[EMUL_MEMSIZE]; +void add(); #endif diff --git a/emul_reg.c b/emul_reg.c index 79d4ca9..8565c22 100644 --- a/emul_reg.c +++ b/emul_reg.c @@ -1,5 +1,15 @@ #include "emul_reg.h" +int reg[32]; + void emul_reg_init() { reg[Szero] = 0; } + +int emul_reg_get(int r) { + return reg[r]; +} + +void emul_reg_set(int r, int value) { + reg[r] = value; +} diff --git a/emul_reg.h b/emul_reg.h index cdb6e59..28d9094 100644 --- a/emul_reg.h +++ b/emul_reg.h @@ -48,10 +48,11 @@ } EMUL_REG; -int reg[32]; - /* initialize register * this must be called */ void emul_reg_init(); +int emul_reg_get(int r); +void emul_reg_set(int r, int value); + #endif