assignment 3 console

PHOTO EMBED

Sun Apr 30 2023 19:15:18 GMT+0000 (Coordinated Universal Time)

Saved by @ahmed_salam21

# MIPS Lab Assignment 3 
# A program to find the greatest of three integer numbers on console

.data
message_1: .asciiz "Enter the first number: "
message_2: .asciiz "Enter the second number: "
message_3: .asciiz "Enter the third number: "
result: .asciiz "The greatest number is: "

.text

    # Ask user to input the first number
    li $v0, 4
    la $a0, message_1
    syscall

    # Read the first number from user input
    li $v0, 5
    syscall
    move $s0, $v0

    # Ask user to input the second number
    li $v0, 4
    la $a0, message_2
    syscall

    # Read the second number from user input
    li $v0, 5
    syscall
    move $s1, $v0

    # Ask user to input the third number
    li $v0, 4
    la $a0, message_3
    syscall

    # Read the third number from user input
    li $v0, 5
    syscall
    move $s2, $v0

    # Find the greatest of the three numbers
    move $t0, $s0
    blt $s1, $t0, greater_than_num1
    move $t0, $s1

greater_than_num1:
    blt $s2, $t0, greater_than_num2
    move $t0, $s2

greater_than_num2:
    # Print the result
    li $v0, 4
    la $a0, result
    syscall

    li $v0, 1
    move $a0, $t0
    syscall

    # Exit the program
    li $v0, 10
    syscall
content_copyCOPY