MIPS -
Takes two inputs from the user, which are the lengths of two sides of a polygon. It adds those two lengths and prints the sum. Your task is modify the program to make it specific to a triangle, and to print the perimeter of that triangle.
See blue highlighted.
PROGRAM:
.data
preamble: .ascii "\nThis program, written by PALLAVI,
"
.asciiz "can be used to add three
sides of a triangle(i.e., Preimeter of a triangle).\n"
prompt1: .asciiz "Enter the length of first side:
"
prompt2: .asciiz "Enter the length of second side:
"
prompt3: .asciiz "Enter the length of third side:
"
answer: .asciiz "Perimeter of triangle is: "
.text
.globl main
main:
li $v0,4 # 4 is the
print_string syscall
la $a0,preamble # Load
the address of preamble into $a0
syscall
# Printhe the preamble
li $v0,4 # 4 is the
print_string syscall
la $a0,prompt1 # Load
the address of prompt1 into $a0
syscall
# Print the prompt
li $v0,5 # 5 is the
read integer syscall
syscall
# read the integer which gets stored in
$v0
move $t0,$v0 # put the
read integer in $t0 for further processing
li $v0,4 # 4 is the
print_string syscall
la $a0,prompt2 # Load
the address of prompt2 into $a0
syscall
# Print the prompt
li $v0,5 # 5 is the
read integer syscall
syscall
# read the integer which gets stored in
$v0
move $t1,$v0 # put the
read integer in $t1 for further processing
li $v0,4 # 4 is the
print_string syscall
la $a0,prompt3 # Load
the address of prompt3 into $a0
syscall
# Print the prompt
li $v0,5 # 5 is the
read integer syscall
syscall
# read the integer which gets stored in
$v0
move $t2,$v0 # put the
read integer in $t2 for further processing
add $t3,$t0,$t1 # $t3 =
a+b i.e., sum of first 2 sides
add $t3,$t3,$t2 # $t3 =
$t3+c i.e., Adding third side to above result
li $v0,4 # 4 is the
print_string syscall
la $a0,answer # Load
the address of answer into $a0
syscall
# Print the answer string
li $v0,1 # 1 is the
print integer syscall
move $a0,$t3 # Put the
value from $t3 in $a0 for printing
syscall
# Print the answer number
li $v0,10 # 10 is the
exit program syscall
syscall
# Exit the program
Please refer to the following screenshot of the program for indentation of the code:
OUTPUT:
MIPS - Takes two inputs from the user, which are the lengths of two sides of...
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...
Subroutines in MIPS Determines the minimum of two integers Functions within the MIPS slides describe how one can use subroutines (also called procedures, functions, and methods) in MIPS. Because of the importance of subroutines in modern programming, most hardware designers include mechanisms to help programmers. In a high-level language like C or Java, most of the details of subroutine calling are hidden from the programmer. MIPS has special registers to send information to and from a subroutine. The registers $a0,...
In the SPIM simulator in MIPS assembly, write the itri routine in the itri.s skeleton to make it print an inverted triangle. The height of the triangle will be given in $a0, and will be between 1 and 40 inclusive. For the first three tests, the included test harness should print (spimsimulator(dot)sourceforge(dot)net) 1. (25 pts.) In the SPIM simulator in MIPS assembly, write the itri routine in the itri.s skeleton to make it print an inverted trian- gle. The height...
Hello, I'm having trouble completing this program in less than four lines using MIPS programming language, we are required to fill in the missing code as indicated (via comments). IMPORTANT: As indicated in the program's comments: ⇒ Write no more than certain number of lines of code as indicated. (One instruction per line, and there will be penalty if your code consumes more lines.) ⇒ Code MUST use only instructions that are allowed i.e., only bit manipulating instructions: (ANDing, ORing,...
.data prompt: .asciiz "Input an integer x:\n" result: .asciiz "Fact(x) = " .text main: # show prompt li $v0, 4 la $a0, prompt syscall # read x li $v0, 5 syscall # function call move $a0, $v0 jal factorial # jump factorial and save position to $ra move $t0, $v0 # $t0 = $v0 # show prompt li $v0, 4 la $a0, result syscall # print the result li $v0, 1 # system call #1 - print int move $a0,...
Assignment 4 File “quad_sol.s” contains a quadratic polynomial solver, which calculates the integer solution of a quadratic polynomial equation. 1. Rewrite the program using instructions reordering to reduce the number of cycles needed to execute the program. Indicate the number of cycle reduction. 2. Describe how forwarding would affect the execution of the program. CODE # quad_sol.s # This assembly program calculates the integer solutions of a quadratic polynomial. # Inputs : The coefficients a,b,c of the equation a*x^2 +...
1. Modify larger.s to let the user to enter three numbers and output the largest value # larger.s-- prints the larger of two numbers specified # at runtime by the user. # Registers used: # $t0 - used to hold the first number. # $t1 - used to hold the second number. # $t2 - used to store the larger of $t1 and $t2. # $v0 - syscall parameter and return value. # $a0 - syscall parameter. .text main: ##...
I have this MIPS program and I'm having trouble with it. This program is user inputs numbers until zero and sorts and print the numbers in order. Please soove this issue. You can use any sorting algorithm except bubble sort. Need it as soon as possible. Here is the code:.datanum: .word 0space: .byte ' ' .text main: # la $t0, val # loads val into a register # li $t1, 0 #keeps track of how many numbers entered la $a0,...
im trying to complete mips program code about a calculator program that can calculate integer addition / subtraction written using the MIPS assembler. im having hard times to debug this. The input is given to the array of Formula char (base address $ s0) in the form of a formula. The null character (\ 0, ASCII code 0) is placed at the end. The calculation result is given to the register $ s1 and the overflow is ignored. For example,...