From 435042774cd03687297a8100e807c70dd7b1b3e4 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Fri, 8 Nov 2013 21:49:39 +0100 Subject: Simulator fixed. --- csim/sim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'csim') diff --git a/csim/sim.c b/csim/sim.c index 94bf70e..3aa09c2 100644 --- a/csim/sim.c +++ b/csim/sim.c @@ -11,7 +11,7 @@ #include "sim.h" -#define DEBUG 1 +#define DEBUG 0 // Util @@ -39,7 +39,7 @@ t_machine *init_machine (t_program *p) { t_value a = 1; char *o = p->vars[i].name + 1; while (*o) { - m->var_values[i] |= a; + if (*o == '1') m->var_values[i] |= a; a >>= 1; o++; } @@ -204,7 +204,7 @@ void machine_step(t_machine *m) { // SAVE REGISTERS && MEMORY for (i = 0; i < p->n_regs; i++) { m->reg_data[i] = m->var_values[p->regs[i].source]; - if (DEBUG) printf("reg %s <- %s : %lx\n", + if (DEBUG) fprintf(stderr, "reg %s <- %s : %lx\n", p->vars[p->regs[i].dest].name, p->vars[p->regs[i].source].name, m->reg_data[i]); -- cgit v1.2.3