{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CDA3101-F11-Recitation05

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

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

CDA 3101 Recitation Session 5

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

View Full Document
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;
Pointers Write MIPS code for p = &z[4]; Let p be at \$t0 and z be at \$a0 move \$t0, 16(\$a0)

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

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

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

View Full Document
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
Binary to Decimal Conversion

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

View Full Document
Decimal to Binary Conversion
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern