Understanding encoding

Assignment 2: MIPS-C
version ,3 Last updated 202211-02 033000
Aims
• Understanding encoding of MIPS instructions • Understanding semantics of MIPS instructions • Generally building a concrete understanding of an example CPU • Practicing C, including bit operations
The Assignment
rn psy is a Min emulator written in Rust. You have extensively used mipsy in COMP1521 to run MIPS programs.
The input to mipsy is usually a file containing MIPS assembly instructions. For example:
S cat examples/42.s main: It Sae, 42 X printf(“Xd”, 42); 11 See, 1 syscall
11 SA, • n’ 4 prIntf(“c”, -161′); 11 Eve, 11 syscall
Jr Sra S 1521 mipsy examples/42.s 42
your task in this assignment is to write mipsc a MIPS emulator written in C. DON’T PANIC mipsc is much simpler than mipsy. mipsc only needs to emulate the small subset of MIPS instructions listed below. These instructions has been chosen to be simpler to emulate, but still allow interesting programs to be run. The input to mipsc is a file containing hexadecimal numbers representing the 32-bit instruction codes of MIPS instructions. mipsc should read these instruction codes (code provided) and then emulate the instructions like this:
5 cat examples/42.hex 2004002o noteeel mese& 2e04000a 2102000k, MONO< Oct edpsc.c -o elms< .firdpsc exaeples/42.hex 0: 0x20040024 add! $4, SO, 42 >» S4 = 42 1: 0N26320001 add! 52, SO. 1 3» 52 = 1 2: exeeeeezec syscall 3» syscall 1 occ 42 3: exzeezeeea add! $4, SO. 10 3» 54 = 10 4: 0x20320006 add! $2, $0. 11 3» 52= 11 5: 0x0000000C syscalt
Aims The Assignment Reference implementation MIPS Instruction Subset System Calls Registers Halting Converting MIPS Assembler Instruction codes Examples Getting Started Assumptions and Clarifications Change log Assessment