Homework Due Feb (a) write MIPs assembly code that will execute the following C
ID: 3792712 • Letter: H
Question
Homework Due Feb (a) write MIPs assembly code that will execute the following C statement. Assume that the following registers are used to represent the variables: a in register in register Ssl, and c in register ss2 a (a b)-(c 33) (b) Replace the C code for a[12]-bl 12] by a set of equivalent MIPs instructions, using as few instructions as possible. Assume that h is h in register S8, and the staring addresses for arrays a and b are stored in registers S4 and S5 respectively. (c) Replace the C code for by a set of equivalent MIPS instructions, using as few instructions as possible. Assume that f and g are in register St1 and St0 respectively, and the staring addresses for arrays A and Bare stored in registers Sa0 and Sal, respectively (a) Follow the instructions below CONSECUTIVELY, and after each instruction write the value of destination register in decimal into the space provided. ori Ss1, Szero, 2 assi sll $s2, Ss1, 3 ass2 andi Ss3, $s2, 19 ASs3 (b) Translate the following C statement into the corresponding MIPS code. Assume that the variables fand g are assigned to registers Ss0 and Ssi and the base address of the arrays Aand B are in register Ss6 and respectively. 3. Memory (a) How many locations of memory can you address with 16-bit address? (b) How many bits are required to address a 4-Mega-location memory, i e., what is the length of the memory address?Explanation / Answer
3 a) A 16-bit register can store2^16 different values. ( The signed range of integer values that can be stored in 16 bits is -32,768(-1*2^15) through 32,767(2^15-1); the unsigned range is 0 through 65,535(2^16-1). Since 2^16 is 65,536. )
A proce with 16 bit memory addresses can directly access 64 kb of byte-addressable memory.
6 i) Instruction in binary:01000001 01100100 01100100 01101001 00101110 00100000 00100100 01100001 00110000
00101100 00100000 00100100 01100001 00110000 00101100 00100000 00101101 00110100
ii) Instruction in binary: 01101100 01110111 00100000 00100100 01110011 00110010 00101100 00100000 00110001 00110010 00111000 00101000 00100100 011100110111001100101001
iii) Instruction in binary: 01000001 01101100 011011000010000000100100 01110100 00110010 00101100 00100000 00100100 01110100 0011001100101100 00100000 00110101
iv) instruction in binary: 01110011 0111010101100010 01110101 00100000 00100100 01110110 00110000 00101100 00100000 00100100 01100001 00110000 00101100 00100000 00100100 01110011 00110000
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.