
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The instructions for completing homework 2 in cpr e 381, which involves installing spim simulator, writing a mips assembly program, and running it with different inputs. Students are required to submit the results for at least three distinct values, explain what the program does, provide a commented source code, and translate it into c code. References to chapter 2 and appendix a of the book are provided.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

.data str1: .asciiz " Please enter a number >= 1 : " str2: .asciiz "\n\n The result is:" .text .globl main
main: li $v0, 4 la $a0, str syscall
li $v0, 5 syscall move $t1, $v
addi $t3, $zero, 1 slti $t2, $t1, 1 beq $t3, $t2, do_nothing
addi $t0, $t0, 0 loop: sge $t2, $t1, $t beq $t2, $zero, end
add $t0, $t0 , $t addi $t1, $t1 , - j loop
end: li $v0, 4 la $a0, str syscall
li $v0, 1 move $a0, $t syscall
do_nothing:
li $v0, 10 syscall