Answer to Question #284640 in Assembler for Monu

Question #284640

Take 4 value in floating point double precision and compare which one is smaller and display the output using MIPS

1
Expert's answer
2022-01-04T01:10:08-0500
# MIPS assembly
#************************************************
.data
EnterN:     .asciiz "Enter Number "
Answer:    .asciiz "\nSmaller: "

    .text
    .globl  main
main:   
    li $v0,4            # print string
    la $a0,EnterN        # "Enter Number"
    syscall                # make the syscall print string
    
#reads and store the Number_1
    li  $v0, 7            # read  Number_1 to $f0
    syscall                # make the syscall read double
    mov.d $f14, $f0

    li $v0,4            # print string
    la $a0,EnterN    # "Enter Number "
    syscall                # make the syscall print string
    
#reads and store the Number_2
    li  $v0, 7            # read Number_2 to $f0
    syscall                # make the syscall read double
    mov.d $f16, $f0
    

    li $v0,4            # print string
    la $a0,EnterN        # "Enter Number "
    syscall                # make the syscall print string
    
#reads and store the Number_3
    li  $v0, 7            # read  Number_3 to $f0
    syscall                # make the syscall read double
    mov.d $f18, $f0

    li $v0,4            # print string
    la $a0,EnterN        # "Enter Number "
    syscall                # make the syscall print string
    
#reads and store the Number_4
    li  $v0, 7            # read  Number_4 to $f0
    syscall                # make the syscall read double
    mov.d $f20, $f0

# Smaller:
    mov.d $f12, $f14        # $f12 = begining smaller

    c.le.d $f12, $f16        # smaller compare with Number_2
    bc1t next1                # smaller <= Number_2
    mov.d $f12, $f16        # else $f12 = new smaller
    
next1:
    c.le.d $f12, $f18        # smaller compare with Number_3
    bc1t next2                # smaller <= Number_3
    mov.d $f12, $f18        # else $f12 = new smaller

next2:    
    c.le.d $f12, $f20        # smaller compare with Number_4
    bc1t smaller            # smaller <= Number_4
    mov.d $f12, $f20        # else $f12 = new smaller    
    

smaller:
    li $v0,4            # print string
    la $a0,Answer        # "Smaller: "
    syscall                # make the syscall print string
    
    li    $v0,3            # Print  
    syscall                # make the syscall print      

finish:    
    li    $v0, 10     
    syscall




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS