recitation_week_5 - .text.globl main main la $a0 A base...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
In this recitation, please mainly help the students in understanding MIPS functions. Help them with jal, jr first, then help them with the stack. Explain the basic concepts to them. Then ask the students to write code to implement a function to find the number of times a value appears in an array with n elements where n is 10 in our case. One of the possible implementations is follows: .data A: .word 12, 34, 67, 1, 45, 90, 11, 33, 67, 19
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: .text .globl main main: la $a0, A # base address li $a1, 10 # n li $a2, 67 # the value to search jal findocr done: li $v0,10 syscall findocr: ori $t0, $zero, 0 ori $v0, $zero, 0 findocrloop: sll $t1, $t0, 2 add $t1, $a0, $t1 lw $t2, 0($t1) bne $t2, $a2, findocrnoinc addi $v0, $v0, 1 findocrnoinc: addi $t0, $t0, 1 beq $t0, $a1, findocrdone j findocrloop findocrdone: jr $ra...
View Full Document

This document was uploaded on 12/04/2011.

Ask a homework question - tutors are online