CDA3101-Fall2011-Recitation04

# CDA3101-Fall2011-Recitation04 - Recitation 4 Pointers...

This preview shows pages 1–7. Sign up to view the full content.

Recitation 4

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Pointers Implement the following in MIPS: //c is an integer variable stored at memory address 0x10000000 with value 8. int * p = &c; int * q = p; int r = *p; *q = 5; //What is the value of *p after this code is executed? What about r?
lui \$s0, 0x1000 # int * p = &c; move \$s1, \$s0 # int * q = p; lw \$s2, 0(\$s0) # int r = *p; li \$t0, 5 sw \$t0, 0(\$s1) # *q = 5; The value of *p is 5 after the code completes. The value of r is 8. Why?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Arrays Implement this in MIPS: int A[3]; A[0] = 2; A[1] = 4; A[2] = 3; Note: In this case, you need to explicitly initialize the array in your code. You cannot assume it is created elsewhere.
.data #allocate mem A: .space 12 #int A[3]; .text #main code la \$t0, A #get A address li \$t1, 2 sw \$t1, 0(\$t0) #A[0] = 2; li \$t1, 4 sw \$t1, 4(\$t0) #A[1] = 4; li \$t1, 3 sw \$t1, 8(\$t0) #A[2] = 3;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
What addressing mode is used in each of the following MIPS instructions? jr \$ra
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 12/10/2011 for the course CDA 3101 taught by Professor Small during the Fall '08 term at University of Florida.

### Page1 / 9

CDA3101-Fall2011-Recitation04 - Recitation 4 Pointers...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online