Docstoc

ex1 probs

Document Sample
ex1 probs Powered By Docstoc
					Computer Systems and Architecture Exercise Sheet 1: Instruction Sets
1. Some simple arithmetic Show how the following code fragments could be written in MIPS assembly language, assuming that all variables are stored in main memory. You should only need to use the following instructions (see the attached list for full details): lw, dw, add, sub, addi, subi, mult a) b) c) d) e) a a a a a = = = = = (b + c) - (d + e); b * ( c + d); b*c + 25; (b + 10)*c – (d – 5); (b + 5)*c + (b – 3);

2. Doing things the other way around Given the following fragments of MIPS assembly code, write the equivalent high-level construct a) lw $r1 , &b lw $r2 , &c sub $r3 , $r1 , $r2 lw $r1 , &d lw $r2 , &e sub $r4 , $r1 , $r2 add $r1 , $r3 , $r4 sw $r1 , &a b) lw $r1 , lw $r2 , lw $r3 , addi $r3 mult $r1 mult $r1 sw $r1 , c) &b &c &d , $r3 , 6 , $r1 , $r2 , $r1 , $r3 &a

lw $r1 , &b addi $r2 , $r0 , 10 mult $r1 , $r1 , $r2 sw $r1 , &a   d)  lw $r1 , &a addi $r1 , $r1 , 1 sw $r1 , &a   e) lw $r1 , &b mult $r1 , $r1 , $r1 lw $r2 , &c subi $r2 , $r2 , 3 add $r1 , $r1 , $r2 sw $r1 , &a

// Hint: r0 is always zero.


				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:8
posted:8/25/2009
language:English
pages:1
Shah Muhammad  Butt Shah Muhammad Butt IT professional
About IM IT PROFESSIONAL