{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CDA 3101 Recitation Session 5
Image of page 1

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

View Full Document Right Arrow Icon
Pointers int z[100], x, y, *p; x = 100; what does *(&x) do? what does &z mean? what does the following statement do? p = &z[10]; what do the following statements do? p = &x ; *p = 200;
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)
Image of page 3

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

View Full Document Right Arrow Icon
Pointers Write MIPS code for *p = 3; As before, let p = $t0 li $s0, 3 sw $s0, 0($t0)
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; }
Image of page 5

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

View Full Document Right Arrow Icon
Solution #$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 # If the last array element is not # reached yet, loop
Image of page 6
Binary to Decimal Conversion
Image of page 7

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

View Full Document Right Arrow Icon
Decimal to Binary Conversion
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern