/* ----------------------------------------------- */ /* A Simulator for the PC-231 Computer */ /* -- batch version: no print, echo, flush, etc. */ /* Fritz Ruehr * Willamette University * Fall 1998 */ /* for CS 231: Introduction to Programming */ /* ----------------------------------------------- */ #include #include "bcmds.c" /* ----------------------------------------------- */ /* Main program: loads program and runs until HALT */ void main(int argc, char* argv[]){ int runFlag = 1 ; int reloadFlag = 1 ; int rerunFlag = 0 ; int DUMP = 0 ; int instr ; /* current instruction */ int opcode ; /* opcode of current instruction */ int args ; /* arguments of current instruction */ int i, j, k ; char c ; printf("\n--------------------------------------------------"); printf("\nWelcome to the PC-231 simulator! [vers. 0.2 BATCH]\n\n"); /* main run loop */ while (runFlag) { /* initialize registers & load program */ haltFlag = 0 ; Reg[PCINDEX] = 0 ; for (i=0; i>=1, k--; i==0){ printf("%d", (n&i)>>k) ; if(k%4==0) printf(" ") ; } } /* ----------------------------------- */ /* END of PC231 simulator program file */ /* ----------------------------------- */