summaryrefslogtreecommitdiff
path: root/csim/sim.c
diff options
context:
space:
mode:
Diffstat (limited to 'csim/sim.c')
-rw-r--r--csim/sim.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/csim/sim.c b/csim/sim.c
index 1dd2791..4451d0e 100644
--- a/csim/sim.c
+++ b/csim/sim.c
@@ -74,6 +74,13 @@ void read_inputs(t_machine *m, FILE *stream) {
t_id var;
t_program *p = m->prog;
+ int magic;
+ fscanf(stream, " %x", &magic);
+ if (magic != 0xFEED) {
+ fprintf(stderr, "(simulator) Protocol error.\n");
+ exit(1);
+ }
+
if (p->n_inputs == 0) return; // nothing to do
for (i = 0; i < p->n_inputs; i++) {
@@ -213,6 +220,8 @@ void write_outputs(t_machine *m, FILE *stream) {
t_value v, mask;
t_program *p = m->prog;
+ fprintf(stream, "FED\n");
+
for (i = 0; i < p->n_outputs; i++) {
var = p->outputs[i];
fprintf(stream, "%s\t", p->vars[var].name);