(Class notes Mon, Mar 28, 2005) Simulate the Simpletron - print welcome message ==> sm_welcome() - initialize memory ==> sm_init_memory( mem ) - initialize registers ==> sm_init_regs( ... ) - run the machine ==> sm_run_machine( acc, instrCtr, instrReg, mem ) - dump machine state ==> sm_dump( ... ) initialize memory - set all memory slots to 0 - i = 0; read data; while (data != -99999) mem[i] = data; i++; read next data run the machine - int machine_running = 1 - while (machine_running) { instrReg = memory[instrCtr] op_code = instrReg / 100; operand = instrReg % 100; switch (op_code) case READ: .... ; break; .... case HALT: machine_running = 0; break; }