/* * Giovanni Agosta, Andrea Di Biagio * Politecnico di Milano, 2007 * * machine.c * Formal Languages & Compilers Machine, 2007/2008 * */ #include "machine.h" /* Debug printf, print the value of the status word */ void print_psw(FILE *file) { /* precondition */ if (file == NULL) file = stderr; fprintf(file, "PSW=[0x%08x]\n", psw); fprintf(file, "CARRY (C):\t %d\nOVERFLOW (V):\t %d\n" "ZERO (Z):\t %d\nNEGATIVE (N):\t %d\n\n" , getflag(CARRY), getflag(OVERFLOW) , getflag(ZERO), getflag(NEGATIVE)); } /* Debug printf, print the content of the register file */ void print_regs(FILE *file) { int i; /* precondition */ if (file == NULL) file = stderr; fprintf(file, "\n*** REGISTER FILE STATUS ***\n"); for (i=0; i