Question

WRITE THE FOLLOWING CODE IN FLOATING POINT NUMBERS IN ASSEMBLY LANGUAGE USING MIPS IN MARS .data...

WRITE THE FOLLOWING CODE IN FLOATING POINT NUMBERS

IN ASSEMBLY LANGUAGE USING MIPS IN MARS

.data
prompt: .asciiz "\nMaximum number is : "
prompt1: .asciiz "\nMinimum number is : "
prompt2: .asciiz "\nRange of the array is : "
size: .word 10

#load array
array: .word 23, -12, 45, -32, 52, -72, 8, 13,22,876

.text
#load address of array and size
la $s4,array #load address of A
lw $t0,size #load i to t0

jal getArrayRange

li $v0, 4   
la $a0, prompt2 #prompt for string
syscall

li $v0, 1   
move $a0, $s2 #prompt for string
syscall

li $v0, 10 #terminate
syscall

getArrayRange:
li $s1,9999
li $s0,0
li $s2,0

loop:

mul $t1,$s2,4 #get index of first element by multiplying it by 4
add $t1,$t1,$s4 #add index to base address of array
lw $s3,0($t1) #load base address to s0


#check for minimum
bge $s0,$s3,skip
move $s0,$s3
skip:

#check for maximum
ble $s1,$s3,skip1
move $s1,$s3
skip1:

addi $s2,$s2,1 #increase i by one
blt $s2,$t0,loop # loop until size

li $v0, 4   
la $a0, prompt #prompt for string
syscall

li $v0, 1   
move $a0, $s0 #prompt for string
syscall

li $v0, 4   
la $a0, prompt1 #prompt for string
syscall

li $v0, 1   
move $a0, $s1 #prompt for string
syscall

sub $s2,$s0,$s1
jr $ra

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below:

.data
prompt: .asciiz "\nMaximum number is : "
prompt1: .asciiz "\nMinimum number is : "
prompt2: .asciiz "\nRange of the array is : "
max : .float 9999
zero : .float 0
size: .word 10

#load array
array: .float 23.5, -12.5, 945.5, -32.5, 52.5, -172.5, 8.5, 13.5,22.5,876.5

.text
#load address of array and size
la $s4,array #load address of A
lw $t0,size #load i to t0

jal getArrayRange

li $v0, 4   
la $a0, prompt2 #prompt for string
syscall

li $v0,2
mov.s $f12,$f2
syscall

li $v0, 10 #terminate
syscall

getArrayRange:
l.s $f1,max
l.s $f0,zero
l.s $f2,zero

loop:

mul $t1,$s2,4 #get index of first element by multiplying it by 4
add $t1,$t1,$s4 #add index to base address of array
l.s $f3,0($t1) #load base address to f0


#check for minimum
c.lt.s $f0,$f3
bc1t skip
j next
skip:
mov.s $f0,$f3
next:
#check for maximum
c.lt.s $f1,$f3
bc1t skip1
mov.s $f1,$f3
skip1:

addi $s2,$s2,1 #increase i by one
blt $s2,$t0,loop # loop until size

li $v0, 4   
la $a0, prompt #prompt for string
syscall

li $v0,2
mov.s $f12,$f0
syscall

li $v0, 4   
la $a0, prompt1 #prompt for string
syscall

li $v0,2
mov.s $f12,$f1
syscall

sub.s $f2,$f0,$f1
jr $ra

output:

Add a comment
Know the answer?
Add Answer to:
WRITE THE FOLLOWING CODE IN FLOATING POINT NUMBERS IN ASSEMBLY LANGUAGE USING MIPS IN MARS .data...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT