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
CODE
Text Code
#Data Segment
.data
prompt: .asciiz "Enter an integer value : "
matched_output: .asciiz "Found Index Is : "
unmatched_output: .asciiz "Not Found : "
#Define the array
list: .word 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 32, 45, 9, 0, 234,
12, 42, 65, 33, 67
#Define the size of array
size: .word 20
#Text Segment
.text
#Main Function Code starts Here
main:
#Give message to user
li $v0, 4 # system call code for printing a string = 4
la $a0, prompt # address of string is argument 0 to
syscall # call operating system to perform operation defined in
register v0
#Input From USer
li $v0, 5 # get ready to read in integers code is 5
syscall # call operating system to perform operation defined in
register v0
# NOTE VALUE IS PRESENT IN value in $v0
move $s0, $v0 #Now register $s0 contains the number entered by
user
la $t1, list # get array address
li $t2, 0 # set loop counter as 0
la $t4, size #get array size address
lw $t3, ($t4) #get size in register $t3
#start the loop
loop:
beq $t2, $t3, loop_end # checking for array end comparing $t2 and
t3 if reaches end then call loop_end
lw $t5, ($t1) # value at the array pointer in register t5
beq $t5, $s0, matched #matching array value with user value if it
matches matched functino is called else continue
addi $t2, $t2, 1 # increment loop counter
addi $t1, $t1, 4 # increment array pointer
j loop # repeat the loop
#This function will be called when we reach the end of
array
#therefore its evident that number is not Found
loop_end:
#Print message First
li $v0, 4 # system call code for printing string = 4
la $a0, unmatched_output # load address of string to be printed
into $a0
syscall # call operating system to perform operation defined in
register v0
#Print -1
li $v0, 1 # system call code for printing int = 1
la $a0, -1 # load integer in a0 register
syscall # call operating system to perform operation defined in
register v0
#terminate the program
li $v0, 10 # terminate program code is 10
syscall # call operating system to perform operation defined in
register v0
#this function is called when we find a match in the array
matched:
#Print message First
li $v0, 4 # system call code for printing string = 4
la $a0, matched_output # load address of string to be printed into
$a0
syscall # call operating system to perform operation defined in
register v0
#Print Index which was in register $t2
li $v0, 1 # system call code for printing int = 1
la $a0, ($t2) # load value in $t2
syscall # call operating system to perform operation defined in
register v0
------------------------------------------------------------------------------------------------------------------------------------------------------
INput Data defined in data segment
Sample Output
Please comment for any further assistance
Linear Search: Write a MIPS assembly language program that can search for a number that entered...
Write a simple and short MIPS assembly language program that asks the user for 6 numbers, merge-sorts them, and then prints them out in ascending order comment each and every programme .(USING WINDOWS QtSpim) Note : This question is not giving desired solution may you please try it in a simple manner for six number inputed by the user.
Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence. Your program should prompt for an integer input n from the user. The program should call a recursive function to compute the nth fibonacci number. Your program must follow programming convention. You should submit program and screenshot of output in a single word/pdf file. You should use following recursive definition of fibonacci function: fib(0) = 0 fib(1) = 1 fib(n) = fib(n-1) +fib(n-2)
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...
2. Searching a String: Write a MIPS assembly language program to do the following: Read a string and store it in memory. Limit the string length to 100 characters. Then, ask the user to enter a character. Search and count the number of occurrences of the character in the string. The search is not case sensitive. Lowercase and uppercase letters should be equal. Then ask the user to enter a string of two characters. Search and count the number of...
MIPS Assembly Language * Write a simple program to count the number of non overlapping repetitions of a character pattern in a character string. For example " the pattern "aa" appears twice in the in the string "aabbaaa". Provide a user interface to read the character pattern and the string.
Mips assembly language. Ask the user for the quantity of integers that the user would like to enter. With each integer entered, a function must be called to store that integer into an array in ascending order. Do not use a sort function. This function will insert the integer into the array in the proper position.
Write a MIPS Assembly language program to request a file name from the user, open the file, read the contents, and write it out to the console.
Write a program to draw this number triangl using MIPS assembly language The number of rows is inputted from keyboard. 6. Write a program to draw this number triangle 1 1〈--|--〉1 The number of rows is inputted from keyboard. 6. Write a program to draw this number triangle 1 1〈--|--〉1 The number of rows is inputted from keyboard.
Convert the following C fragment to equivalent MIPS assembly language Write mini calculator that take two integer numbers as input and ask the user if he need to compute addition, subtraction, remainder, division, or multiplication then print the result. Hint: you can give each operation a special number. For example, the addition (1), subtraction (2), …. And so on. The output must be something like: Enter the first integer number: 5 Enter the second integer number: 3 Which operation? 1...
Assembly Language////Write a program that read in 10 integers from the user. Save the numbers into an array; reverse the array and display the reversed array. .data arrayInt DWORD 10 DUP(?) Your program consists of 4 procedures: 1. main procedure: call procedures getInput, reverseArray, displayArray 2. getInput procedure: prompt user to enter 10 integer numbers, save the numbers into the memory for the arrayInt 3. reverseArray: reverse arrayInt 4. displayArray: display the reversed array