Lab2_mips

docx

School

University of Massachusetts, Lowell *

*We aren’t endorsed by this school

Course

2030

Subject

Computer Science

Date

Jan 9, 2024

Type

docx

Pages

2

Uploaded by BarristerRoseMouse35

Report
COMP 2030R Lab 2 9/20/23 NAME: ___________________________________________ 1. MIPS has two groups of data transfer instructions: ‘load’ to store data in a register and ‘store’ to save register data in a memory location. ‘load’ has four variations: li $t0, 3 # load immediate: store a constant in a register la $t0, A # load address: store an address (label) in a register lw $t0, A($t9) # load word: fetch a word (4 bytes) from memory to store in a register lb $t0, A($t9) # load word: fetch a single byte from memory to store in a register Given the three integers in the data segment, consider the program below. In the comment, write the updated value of the destination register when the instruction completes its execution. Assume the data segment starts at address 0x1100. .data array: .word 0x37, 0x55, 0xF .text la $s0, array # $s0 = 0x1100 la $s1, array+4 # $s1 = 0x1104 la $s2, 8($s0) # $s2 = li $a0, 4 # $a0 = lw $t0, 0($s0) # $t0 = lw $t3, array($a0) # $t3 = lw $t1, 8($s0) # $t1 = lb $t2, ($s0) # $t2 =
2. Suppose you have a 10-element array ‘ arr ’ with integers (words), declared with initial values of 0: .data arr: .word 0:10 a. Write MIPS instructions to store $t0 and $t1 to the first and second elements of arr . b. Write MIPS instructions to add the 2 nd and 3 rd elements of arr and save the sum in the 4 th element. 3. Suppose that all numbers are limited to 6-bit binary quantities. In parentheses, write decimal values of the given binary numbers. a. x=001011 ( ) Left shift x by one bit, and write the resulting binary bit sequence and its decimal equivalent in the parenthesis. y= ____________ ( ) b. Let’s say that the binary sequence in part (a) is called ‘y.’ Left shift y by one bit, and write the resulting binary bit sequence and its decimal equivalent in the parenthesis. ____________ ( ) c. z=011010 ( ) Right shift z by one bit, and write the resulting binary bit sequence and its decimal equivalent in the parenthesis. ____________ ( ) d. The left shift of x by one bit is writtein in C as y = x << 1; What arithmetic operation is equivalent to a left shift by one bit? Rewrite the statement y=x<<1 using only arithmetic operations (+, -, *, or /): y = ___________ ;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help