Question
WRITE THE FOLLOWING CODE IN FLOATING POINT NUMBERS IN ASSEMBLY LANGUAGE USING MIPS IN MARS .data prompt: .asciiz Maximum number is : prompt1:
WRITE THE FOLLOWING CODE IN FLOATING POINT NUMBERS
IN ASSEMBLY LANGUAGE USING MIPS IN MARS
.data prompt: .asciiz " Maximum number is : " prompt1: .asciiz " Minimum number is : " prompt2: .asciiz " Range 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started