CDA3101-F11-Recitation05

CDA3101-F11-Recitation05 - CDA 3101 Recitation Session 5...

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

View Full Document Right Arrow Icon
CDA 3101 Recitation Session 5
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 int z[100], x, y, *p; x = 100; what does *(&x) do? what does the following statement do? p = &z[10]; what do the following statements do? p =
Background image of page 2
Pointers Write MIPS code for p = &z[4]; Let p be at $t0 and z be at $a0 move $t0, 16($a0)
Background image of page 3

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

View Full DocumentRight Arrow Icon
Pointers Write MIPS code for *p = 3; As before, let p = $t0 li $s0, 3 sw $s0, 0($t0)
Background image of page 4
Pointers Implement the following in MIPS int pro (int* array, int size) { int* p; for (p=&array[0]; p<&array[size]; p=p+1) *p = 0; }
Background image of page 5

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

View Full DocumentRight Arrow Icon
#$a0 stores the address of the first array element #$a1 stores the size of the array sll $t1, $a1, 2 # Array bytes= Array size * 4 add $t2, $a0, $t1 # Address of last element = address of first # element + Array bytes move $t0, $a0 # Point to the first array element Loop: sw $zero, 0($t0) # Set this element to zero addi $t0, $t0, 4 # Point to next array element slt $t3, $t0, $t2 # Is the pointer at the last array element? bne $t3, $zero, Loop
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 / 18

CDA3101-F11-Recitation05 - CDA 3101 Recitation Session 5...

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