/* Author : Rick van der Zwet * S-number : 0433373 * Version : $Id: constant.c 361 2007-12-03 04:27:55Z rick $ * Copyright : FreeBSD Licence * Description : MIPS simulator. Main module */ #include #include #include #include "sim.h" #include "constant.h" word constant_call(const const_control_t action) { word out = 0; switch (action) { case C0: out = 0; break; case C1: out = 1; break; case C2: out = 2; break; case C3: out = 3; break; case C4: out = 4; break; case C5: out = 8; break; case C6: out = 16; break; case C7: out = 24; break; case C8: out = 31; break; case C9: /* 11110000 00000000 00000000 00000000 */ out = 0x1E000000; break; case C10: /* 00000000 00000000 11111111 11111111 */ out = 0x0000FFFF; break; case C11: /* 00000000 11111111 11111111 11111111 */ out = 0x00FFFFFF; break; case C12: /* 11111111 11111111 11111111 11111100 */ out = 0xFFFFFFFC; break; default: fprintf(stderr, "Constant action not implemented\n"); exit(EX_SOFTWARE); break; } return (out); }