assign4.asm - #Programer Tan Dao#Csc 230 ID 73942 Assigment...

This preview shows page 1 - 2 out of 2 pages.

#Programer: Tan Dao #Csc 230 ID: 73942 # Assigment 4 #professor: Debra Callis #September,30,2019 .data # add any strings at this point as needed .asciiz "Enter a number " .asciiz "\n" .word 0 .word 0 .text .globl main main: addi $a0, $0, 2 # set minimum value as 1 addi $a1, $0, 5 # set maximum value as 15 jal getinput # get a positive number for the loop addi $s0, $v0, 0 # save input value repeat: beq $s0, $0, end # while there are more repeats addi $a0, $0, 1 # set minimum value as 1 addi $a1, $0, 15 # set maximum value as 15 jal getinput # get a value from 1..15 ori $s1, $v0, 0 # save the result addi $a0, $0, 3 # set minimum value as 3 addi $a1, $0, 18 # set maximum value as 18 jal getinput # get a value from 4..18 ori $a1, $v0, 0 # set the second parameter for printsum ori $a0, $s1, 0 # set the first parameter for printsum jal printsum # call function to print sum of input addi $s0, $s0, -1 # decrement counter j repeat # do it again end: ori $v0, $0, 10 # set command to stop program, syscall # end program getinput: lui $s7,0x1001 # set the location 0x1001 at s7 # save the fist input number to location 20 in s7 by location

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture