/* Author : Rick van der Zwet * S-number : 0433373 * Version : $Id: imm.c 365 2007-12-03 08:54:04Z rick $ * Copyright : FreeBSD Licence * Description : MIPS simulator. Main module */ #include #include #include #include "sim.h" #include "imm.h" #include "alu.h" word imm_call(const word in, const imm_control_t action) { word out = 0; switch (action) { case S16: out = alu_sra(in << 16, 16); break; case SSA: out = alu_sra(in << 21, 27); break; case U26: out = in & 0x03FFFFFF; break; case Z16: out = in & 0x0000FFFF; break; case S16x4: out = alu_sra(in << 16, 14); break; default: fprintf(stderr, "IMM action '%i' not implmented\n", action); exit(EX_SOFTWARE); break; }; return (out); }