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...
The program I'm using is MIPS (mars) assembly; Write a program that in the main routine ask the user input n numbers(2<n<11) and pass n and array pointer to FillArray to stores numbers in the array. Main again passes the pointer to AddElement Function to add the elements of the array, and return the result back to main to print it.
MIPS - assembly language Task I (1 mark): Write a program to calculate the nth Fibonacci number based on an iterative approach where value n is read from the keyboard and stored in your main program that is calling fib. The main program reads number ‘n’ -- restrict range of ‘n’ to 2-50, and display an error message if this condition is not satisfied. The main program calls fib with parameter passing. Procedure fib should return the calculated...
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
IN MIPS PLEASE. Need help writing a MIPS program that reads from a text file named "input.txt" and places it in a buffer. A buffer of 80 bytes is more than enough. Before you call your function, set $a0 equal to the address of the filename and $a1 to the address of the buffer where data is stored. The function should return the number of bytes read in $v0. In the main program, print an error message and terminate the...
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...
Write a procedure, bfind( ), in C code using pointer-based and convert it into MIPS assembly language with clear and necessary comments. The procedure should take a single argument that is a pointer to a null-terminated string in register $a0. The bfind procedure should locate the first character b in the string and return its address. If there are no b’s in the string, then bfind should return a pointer to the null character at the end of the string....