Respuesta :
Answer:
Explanation:
.data
msg1: .asciiz "Enter the floating point value = "
msg2: .asciiz "\nEnter the shape (Circle - 1, Triangle - 2, Square - 3) = "
msg3: .asciiz "\nThe perimeter of the triangle with side = "
msg4: .asciiz " meters is "
msg5: .asciiz " meters.\n"
msg6: .asciiz "\nThe area of the triangle with side = "
msg7: .asciiz " square meters.\n"
msg8: .asciiz "\nThe circumference of the circle with radius = "
msg9: .asciiz "\nThe area of the circle with radius = "
msg10: .asciiz "\nThe perimeter of the square with side = "
msg11: .asciiz "\nThe area of the square with side = "
pi: .float 3.1415816
eq_tr_area: .float 0.43305186
two: .float 2
three: .float 3
four: .float 4
.text
li $v0,4 # system call code for printing string = 4
la $a0,msg1 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
li $v0,6 # system call code for reading floating point number
syscall # call operating system to perform read operation
li $v0,4 # system call code for printing string = 4
la $a0,msg2 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
li $v0,5 # system call code for reading integer
syscall # call operating system to perform read operation
move $t0,$v0
IF:
bne $t0,1,ELSE_IF #if not 1 then goto elseif
li $v0,4 # system call code for printing string = 4
la $a0,msg8 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f0 #move the single precision f2 in f12
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg4 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
l.s $f1,pi
l.s $f3,two
mul.s $f3,$f3,$f1 #calculate 2*pi*radius
mul.s $f3,$f3,$f0
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f3 #move the single precision f2 in f12
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg5 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg9 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f0 #move the single precision f2 in f12
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg4 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
mul.s $f2,$f0,$f0 #calculate radius *radius
mul.s $f2,$f2,$f1 #calculate pi *r^2
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f2 #move the single precision f2 in f12
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg7 # load address of string to be printed into $a0
syscall
ELSE_IF:
bne $t0,2,ELSE #if not 2 then check else
li $v0,4 # system call code for printing string = 4
la $a0,msg3 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f0 #move the single precision f2 in f12
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg4 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
l.s $f3,three
mul.s $f3,$f3,$f0 #calculate 3*side
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f3 #move the single precision f2 in f12
syscall # call operating system to perform print operation
li $v0,4
la $a0,msg5
syscall
li $v0,4
la $a0,msg6
syscall
li $v0, 2
mov.s $f12,$f0
syscall
li $v0,4
la $a0,msg4
syscall
l.s $f3,eq_tr_area
mul.s $f2,$f0,$f0
mul.s $f2,$f2,$f3
li $v0, 2
mov.s $f12,$f2
syscall
li $v0,4
la $a0,msg7
syscall
ELSE:
bne $t0,3,END
li $v0,4
la $a0,msg10
syscall
li $v0, 2
mov.s $f12,$f0
syscall
li $v0,4
la $a0,msg4
syscall
l.s $f3,four
mul.s $f3,$f3,$f0
li $v0, 2
mov.s $f12,$f3
syscall
li $v0,4
la $a0,msg5
syscall
li $v0,4
la $a0,msg11
syscall
li $v0, 2
mov.s $f12,$f0
syscall
li $v0,4
la $a0,msg4
syscall
mul.s $f2,$f0,$f0
li $v0, 2
mov.s $f12,$f2
syscall
li $v0,4
la $a0,msg7
syscall
END:
li $v0,10
syscall
Code is as follows:
.data
msg1: .asciiz "Enter the floating point value = "
msg2: .asciiz "\nEnter the shape (Circle - 1, Triangle - 2, Square - 3) = "
msg3: .asciiz "\nThe perimeter of the triangle with side = "
msg4: .asciiz " meters is "
msg5: .asciiz " meters.\n"
msg6: .asciiz "\nThe area of the triangle with side = "
msg7: .asciiz " square meters.\n"
msg8: .asciiz "\nThe circumference of the circle with radius = "
msg9: .asciiz "\nThe area of the circle with radius = "
msg10: .asciiz "\nThe perimeter of the square with side = "
msg11: .asciiz "\nThe area of the square with side = "
pi: .float 3.1415816
eq_tr_area: .float 0.43305186
two: .float 2
three: .float 3
four: .float 4
.text
li $v0,4 # system call code for printing string = 4
la $a0,msg1 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
li $v0,6 # system call code for reading floating point number syscall # call operating system to perform read operation
li $v0,4 # system call code for printing string = 4 la $a0,msg2 # load address of string to be printed into $a0 syscall # call operating system to perform print operation
li $v0,5 # system call code for reading integer syscall # call operating system to perform read operation move $t0,$v0
IF:
bne $t0,1,ELSE_IF #if not 1 then goto elseif
li $v0,4 # system call code for printing string = 4
la $a0,msg8 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
li $v0, 2 # system call code for printing float = 2 mov.s $f12,$f0 #move the single precision f2 in f12 syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4 la $a0,msg4 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
l.s $f1,pi l.s $f3,two
mul.s $f3,$f3,$f1 #calculate 2*pi*radius
mul.s $f3,$f3,$f0
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f3 #move the single precision f2 in f12
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg5 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg9 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f0 #move the single precision f2 in f12
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg4 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
mul.s $f2,$f0,$f0 #calculate radius *radius
mul.s $f2,$f2,$f1 #calculate pi *r^2
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f2 #move the single precision f2 in f12
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg7 # load address of string to be printed into $a0
syscall
ELSE_IF:
bne $t0,2,ELSE #if not 2 then check else
li $v0,4 # system call code for printing string = 4 la $a0,msg3 # load address of string to be printed into $a0 syscall # call operating system to perform print operation
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f0 #move the single precision f2 in f12
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg4 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
l.s $f3,three
mul.s $f3,$f3,$f0 #calculate 3*side
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f3 #move the single precision f2 in f12
syscall
bne $t0,3,END #if not 3 then end
li $v0,4 # system call code for printing string = 4
la $a0,msg10 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f0 #move the single precision f0 in f12
syscall # call operating system to perform print operation
li $v0,4 # system call code for printing string = 4
la $a0,msg4 # load address of string to be printed into $a0
syscall # call operating system to perform print operation
l.s $f3,four # multilply by 4
mul.s $f3,$f3,$f0 #calculate 4*side
li $v0, 2 # system call code for printing float = 2
mov.s $f12,$f3 #move the single precision f3 in f12
syscall # call operating system to perform print operation
END:
li $v0,10 # system call code for printing exit (end of program)
syscall # call operating system to perform print operation
Learn More:https://brainly.com/question/10169933




