{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

arrays or pointers - Procedures and arrays in MIPS/SPIM...

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

View Full Document Right Arrow Icon
Summer 2002 ICOM 4206 – Functions and arrays Procedures and arrays in MIPS/SPIM Dealing with arrays Same idea using pointers Moving everything you can outside the loop
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
Summer 2002 ICOM 4206 – Functions and arrays Comparing array and pointer code MIPS code for clearing an array using indices move $t0,$zero loop1: add $t1,$t0,$t0 add $t1,$t1,$t1 add $t2,$a0,$t1 sw $zero,0($t2) addi $t0,$t0,1 slt $t3,$t0,$a1 bne $t3,$zero,$loop1 MIPS code for clearing an array using pointers move $t0,$a0 loop1: sw $zero,0($t0) addi $t0,$t0,4 add $t1,$a1,$a1 add $t1,$t1,$t1 add $t2,$a0,$t1 slt $t3,$t0,$t2 bne $t3,$zero,$loop1
Image of page 2
Summer 2002 ICOM 4206 – Functions and arrays Optimizing by moving unnecessary code outside of the loop MIPS code for clearing an array using pointers move $t0,$a0 loop1: sw $zero,0($t0) addi $t0,$t0,4 add $t1,$a1,$a1 add $t1,$t1,$t1 add $t2,$a0,$t1 slt $t3,$t0,$t2 bne $t3,$zero,$loop1 Faster MIPS code for clearing an array using pointers move $t0,$a0 add $t1,$a1,$a1 add $t1,$t1,$t1 add $t2,$a0,$t1 loop1: sw $zero,0($t0) addi $t0,$t0,4 slt $t3,$t0,$t2 bne $t3,$zero,$loop1
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
Summer 2002 ICOM 4206 – Functions and arrays What you need to be able to do Run the assembler/simulator (SPIM) Try it with a known good file first – test1.asm from ece/~bvelez is a good one Write code for simple expressions Try it with registers only - $s4=($s2-$s1)-($s3-4) and a few variations – again it is like working with your high school handheld Write HLL control statements using set instructions, b and conditional branches Be able to do if, while, do while, for Write and call functions Simple leaf function Factorial – this shows recursive functions lr, etc. are procedure calls – jump and store the return address
Image of page 4
Summer 2002 ICOM 4206 – Functions and arrays New assignment Floating point in SPIM Will be graded in happy hour Happy hour is diagnostic as well as grading, if you aren’t sure, ask You need to know SPIM and how to operate it Breakpoints Running a program Interpreting memory and register contents Explaining floating-point formats to some extent Remember to: Surf the web Embed program in a loop of Get data Calculate Display data And remember to always use prompts for input data
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
Summer 2002 ICOM 4206 – Functions and arrays Programming functions Leaf functions
Image of page 6
Image of page 7
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