Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Robert Entenmann
- #04/15/2018
- #Find Minimum and Maximum of 4 numbers
- .data
- Num1: .word 0
- Num2: .word 0
- Num3: .word 0
- Num4: .word 0
- Min1: .word 0
- Max1: .word 0
- Min2: .word 0
- Max2: .word 0
- Min3: .word 0
- Max3: .word 0
- msg1: .asciiz "Please input a number: "
- msg2: .asciiz "Please input a number: "
- msg3: .asciiz "The maximum of the four numbers is "
- msg4: .asciiz "The minimum of the four numbers is "
- .text
- .globl main #Start of main
- .ent main
- main:
- jal readtwo
- sw $t0, Num1
- sw $t1, Num2
- jal findminmax
- sw $t2, Min1
- sw $t3, Max1
- jal readtwo
- sw $t0, Num3
- sw $t1, Num4
- jal findminmax
- sw $t2, Min2
- sw $t3, Max2
- jal findminmax
- sw $t2, Min3
- sw $t3, Max3
- li $v0, 4
- la $a0, msg3
- syscall
- lw $a0, Max3
- li $v0, 1
- syscall
- li $v0, 4
- la $a0, msg4
- syscall
- lw $a0, Min3
- li $v0, 1
- syscall
- .end main #End of main
- .globl readtwo #Start of readtwo function
- .ent readtwo
- readtwo:
- li $v0, 4 #prompts user to input a number
- la $a0, msg1
- syscall
- li $v0, 5 #Gets users input
- syscall
- move $t0, $v0
- li $v0, 4 #prompts user to input a second number
- la $a0, msg2
- syscall
- li $v0, 5 #Gets users second input
- syscall
- move $t1, $v0
- jr $ra
- .end readtwo #End of readtwo function
- .globl findminmax #Start of findminmax function
- .ent findminmax
- findminmax:
- bgt $t3, $t0, $t1
- blt $t2, $t0, $t1
- jr $ra
- .end findminmax #End of findminmax function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement