CDA3101-Fall2011-Recitation04

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

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

View Full Document Right Arrow Icon
Recitation 4
Background image of page 1

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

View Full DocumentRight Arrow Icon
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?
Background image of page 2
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?
Background image of page 3

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

View Full DocumentRight Arrow Icon
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.
Background image of page 4
.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;
Background image of page 5

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

View Full DocumentRight Arrow Icon
What addressing mode is used in each of the following MIPS instructions? jr $ra
Background image of page 6
Image of page 7
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 Right Arrow Icon
Ask a homework question - tutors are online