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

Info iconThis 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
Background image of page 1

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

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

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

View Full DocumentRight 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
Background 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
Summer 2002 ICOM 4206 – Functions and arrays Programming functions Leaf functions These do not call other functions
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 09/23/2009 for the course CMPEN 331 taught by Professor Bhat during the Fall '08 term at Pennsylvania State University, University Park.

Page1 / 17

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

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