Q-1: Write a program in Assembly language using MIPS instruction
set that reads 15 integer numbers from user and stores all the
numbers in the array intArray. Now, read another integer number N
from the user, find the total number of array elements that are
greater or equal to the number N, and the total number of array
elements that are lower than the number N You must have two
procedures: i. ReadIntegerArray: this procedure should read integer
array elements from the user and store it in the array intArray.
Argument $a0: base address of the array intArray should be passed
as parameter. Return value: No need to return any value. ii.
CalcDeviation: This procedure should find the total number of array
elements that are greater or equal to the number N and the total
number of array elements that are lower than the number N. Argument
$a0: base address of the array intArray should be passed. Return
value $v0: number of array elements that are greater or equal to
the number N Return value $v1: number of array elements that are
lower than the number N. Main part of your program should read an
integer number N, call the procedure ReadIntegerArray and
CalcDeviation. At the end, the program should print the values that
are returned by the procedute CalcDeviation.
.data
msg1: .asciiz "Enter 15 integer numbers:\n"
msg2: .asciiz "Enter an integer number N:\n"
msg3: .asciiz "\nNumber of elements greater or equal to N:"
msg4: .asciiz "\nNumber of elements lower than N:"
intArray: .space 60
.text
main:
#print message
li $v0, 4 #print string syscall value is 4
la $a0, msg1 #load address of msg1 to $a0
syscall
la $a0,intArray
jal ReadIntegerArray
#print message
li $v0, 4 #print string syscall value is 4
la $a0, msg2 #load address of msg1 to $a0
syscall
la $a0,intArray
jal CalcDeviation
move $t0,$v0
move $t1,$v1
#print message
li $v0, 4 #print string syscall value is 4
la $a0, msg3 #load address of msg1 to $a0
syscall
#print no.of elements greater than or equal to N
li $v0,1 #print integer syscall value is 1
move $a0,$t0 #copy value in $t0 to $a0
syscall
#print message
li $v0, 4 #print string syscall value is 4
la $a0, msg4 #load address of msg1 to $a0
syscall
#print no.of elements less than to N
li $v0,1 #print integer syscall value is 1
move $a0,$t1 #copy value in $t1 to $a0
syscall
#terminate the program
li $v0, 10
syscall
ReadIntegerArray:
li $s0,0
loop1:
#read integer from user
li $v0,5 #read integer syscall value is 5
syscall #read value stored in $v0
sw $v0,0($a0) #load each element into array
addi $a0,$a0,4 #increase address of array
addi $s0,$s0,1 #increase the count
#bne for not equal,if $s0 not equal to 15
#jump to label loop
bne $s0,15,loop1
#return to called function
jr $ra
CalcDeviation:
#read integer from user
li $v0,5 #read integer syscall value is 5
syscall #read value stored in $v0
move $t0,$v0 #load each N value to $t0
li $v0,0
li $v1,0
li $s0,0
#loop to find the number of elements greater than equal to N
#and number of elements less than N
loop2:
#load value in array to $t3
lw $t3,0($a0)
#increase the address of array
addi $a0,$a0,4
#branch for equa,if $s0 equal to 15
#jump to label exit
beq $s0,15,exit
#increase the count
addi $s0,$s0,1
#branch for greater than equal.
#if $t3 greater than or equal $t0,jump to label greater
bge $t3,$t0,greater
#if less than N,increase the $v1 by 1
addi $v1,$v1,1
j loop2
greater:
#increase the $v0 by 1
addi $v0,$v0,1
j loop2
exit:
#return to called function
jr $ra
Q-1: Write a program in Assembly language using MIPS instruction set that reads 15 integer numbers...
1. Write a program in Assembly language using MIPS instruction set that reads two integer numbers from the user named as start and end number and finds out all the prime numbers between start and end (including start and end). Your program should do the validation of both the numbers as follows: i. start number must be smaller or equal to the end number. ii. Both numbers must be positive. iii. The maximum value for the end number is 10000...
Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to track the number of Deer Hunting Licenses issued in a county and the state. It will display a menu with 5 choices numbered 1-5. They are (1) update the count, (2) display the number of licenses already issued to a county whose number is input, (3) display the county number and the number of licenses already issued to a range of counties whose starting...
ASSEMBLY LANGUAGE (Mars MIPS)
Starting code:
Factorial: #Factorial Recursive function
subu $sp, $sp, 4
sw $ra, 4($sp) # save the return address on stack
beqz $a0, terminate # test for termination
subu $sp, $sp, 4 # do not terminate yet
sw $a0, 4($sp) # save the parameter
sub $a0, $a0, 1 # will call with a smaller argument
jal Factorial
# after the termination condition is reached these lines
# will be executed
lw $t0, 4($sp) # the argument I...
Q#1 Write a C++ program that reads n integer values and stores them in an array of maximum 20 integers. Read from the user a valid value of n (n should not exceed 20). After reading the n array elements find the maximum and minimum elements.
Linear Search: Write a MIPS assembly language program that can search for a number that entered by user in an array with 20 integer numbers and prints the index of the number in the array if it is found and -1 if not found
Introduction: In this lab, you will write a MIPS program to read in (up to) 50 integer values from the user, store them in an array, print out the amay, one number per line, reverse the elements in the array and finally print out the elements in the just-reversed) array. Feel free to do this lab and all assembly programming labs) in Windows. You must use MARS Getting started: l. In MARS, create a new assembly file with the name...
Need to write a MIPS assembly program that finds the minimum and maximum and sum of a stored array. It also finds the locations of the minimum and maximum. The interaction between the main program and the function is solely through the stack. The function stores $ra immediately after being called and restores $ra before returning to main. The main program reserves a static C like array (index starts from 0) of 10 elements and initializes it. The maximum should...
This is a function. PLEASE
ANSWER IN MIPS Basic assembly language.
No psuedo like li, la, move, etc.
Thank you.
2. int readData (&array): The starting address of an array is passed to the function as a parameter using Sa0. The function must prompt for and read and store integers in the array until either a zero is entered or 10 numbers are read. Once the tenth integer is entered, your program must stop reading. The function must return (using...
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...
Write a MIPS procedure using spim or MARS that implements the assignment A[k] = 28 for some specified value of k, where A is an integer array with elements indexed starting from 0. Your procedure should take as its arguments the base address of the array A, and the index k of the array element that is the target of the assignment. You must use the standard procedure conventions discussed in class. You do not need to write a main...