Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lab 2 –MIPS Assembly language li $s6,268500992 li $s3,3 li $s5,10 li $t0,10 sw $

ID: 667116 • Letter: L

Question

Lab 2 –MIPS Assembly language

li $s6,268500992

li $s3,3

li $s5,10

li $t0,10

sw $t0, 0($s6)

sw $t0, 4($s6)

sw $t0, 8($s6)

sw $t0, 12($s6)

sw $t0, 16($s6)

sw $t0, 20($s6)

sw $t0, 24($s6)

sw $t0, 28($s6)

li $t0,2

sw $t0, 32($s6)

loop: sll $t1,$s3,2

add $t1,$t1,$s6

lw $t0,0($t1)

bne $t0,$s5,exit

addi $s3,$s3,1

j loop

exit:

Observe the registers/Memory locations values after each Step Run. Record these values in Table 1.

You should type or copy and paste the values from the Mars environment to the table below using Microsoft office.

$s3

$s5

$s6

$t0

$t1

m[$s6]

m[$s6+4]

m[$s6+8]

m[$s6+12]

m[$s6+16]

m[$s6+20]

m[$s6+24]

m[$s6+28]

1

2

3

4

Questions:

Draw the memory and its contents starting from address 268500992.

What does the final value of $s3 represent?

I only included 4 rows from the table but if you could please explain the process for finding the m[$s6], m[$s6+4] etc table values so I can figure out the rest of the fields that would be appreciated.

$s3

$s5

$s6

$t0

$t1

m[$s6]

m[$s6+4]

m[$s6+8]

m[$s6+12]

m[$s6+16]

m[$s6+20]

m[$s6+24]

m[$s6+28]

1

2

3

4

Explanation / Answer

Hi,

Below is the solution to your problem:

$s3

$s5

$s6

$t0

$t1

m[$s6]

m[$s6+4]

m[$s6+8]

m[$s6+12]

m[$s6+16]

m[$s6+20]

m[$s6+24]

m[$s6+28]

3

10

268500992

10

10

11

12

13

14

15

16

268500992+4

268500992+8

Register
Number

Alternative
Name

Description

0

zero

the value 0

1

$at

(assembler temporary) reserved by the assembler

2-3

$v0 - $v1

(values) from expression evaluation and function results

4-7

$a0 - $a3

(arguments) First four parameters for subroutine.
Not preserved across procedure calls

8-15

$t0 - $t7

(temporaries) Caller saved if needed. Subroutines can use w/out saving.
Not preserved across procedure calls

16-23

$s0 - $s7

(saved values) - Callee saved.
A subroutine using one of these must save original and restore it before exiting.
Preserved across procedure calls

24-25

$t8 - $t9

(temporaries) Caller saved if needed. Subroutines can use w/out saving.
These are in addition to $t0 - $t7 above.
Not preserved across procedure calls.

26-27

$k0 - $k1

reserved for use by the interrupt/trap handler

28

$gp

global pointer.
Points to the middle of the 64K block of memory in the static data segment.

29

$sp

stack pointer
Points to last location on the stack.

30

$s8/$fp

saved value / frame pointer
Preserved across procedure calls

31

$ra

return address

1.:

li          register_destination, value #load immediate value into destination register

              $s3=3

      2. li $s5,10:load immediate:

li          register_destination, value #load immediate value into destination register

              $s5=10

       3. li $s6,268500992:load immediate:

li          register_destination, value #load immediate value into destination register

               $s6=268500992

      4. li $t0,10:load immediate:

li          register_destination, value #load immediate value into destination register

              $t0=10

    5. sw $t0, 0($s6): based or indexed addressing:

    sw $t0, 0($s6)

Store Contents of $t0=10 into RAM at address ($s6 0)

Note: based addressing is especially useful for:

sw $t0, 4($s6)àStore contents of $t0=10 into RAM at address($s6 4)

sw $t0, 8($s6)à Store contents of $t0=10 into RAM at address($s6 8)

sw $t0, 12($s6)à Store contents of $t0=10 into RAM at address($s6 12)

sw $t0, 16($s6)à Store contents of $t0=10 into RAM at address($s6 16)

sw $t0, 20($s6)à Store contents of $t0=10 into RAM at address($s6 20)

sw $t0, 24($s6)à Store contents of $t0=10 into RAM at address($s6 24)

6. li $t0,2-à li $t0,2:load immediate:

li          register_destination, value #load immediate value into destination register

              $t0=2

7. loop: sll $t1,$s3,2:

Convert to assembly: while (save[i] == k) i += 1;

i and k are in $s3 and $s5 and base of array save[] is in $s6

Loop: sll $t1, $s3, 2

add $t1, $t1, $s6

lw $t0, 0($t1)

bne $t0, $s5,

addi $s3, $s3, 1 j Loop

Exi

Hope that helps...HAPPY ANSWERING!!!!!!!!!!!!!!!!!!!!

                                                                                                                                       

$s3

$s5

$s6

$t0

$t1

m[$s6]

m[$s6+4]

m[$s6+8]

m[$s6+12]

m[$s6+16]

m[$s6+20]

m[$s6+24]

m[$s6+28]

3

10

268500992

10

10

11

12

13

14

15

16

268500992+4

268500992+8