Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an Intel x86 assembly language program that will search arrays of unsigned word (16-bit) integers which have previously been sorted into ascending order to

image text in transcribed

Write an Intel x86 assembly language program that will search arrays of unsigned word (16-bit) integers which have previously been sorted into ascending order to determine whether a supplied value is in a given array. Your program must make use of a searching procedure that does the following: Search (using a binary search algorithm) an array of n unsigned word integers (that has already been sorted into ascending numerical order) starting at address m, for the presence of a particular item i. The number of array elements n, the array starting offset m, and the value to search for i, must be passed to the subprogram in registers. (No other information may be passed into or used by the search procedure, nor may it refer by name to the array being searched.) If the supplied value matches any element of the array being searched, the memory offset of the matching element must be returned to the calling program in a register. If the supplied value does not match any of the array elements, a value of all ones (FFFF or FFFFFFFF hexadecimal, as appropriate) must be returned in the designated register instead. Your program must use assembler directives to define two arrays (one of 16 elements and one of 25 elements) and initialize them to contain the following data, respectively: Array 1 initial contents: 0, 1, 4,12, 20, 21, 35, 65, 123, 127, 128, 211,1000, 2006,14111, 60000. Array 2 initial contents: 2, 7,15,17, 72, 73, 74, 100, 122, 130, 146, 300, 543, 655, 1024, 1066, 1961, 2000, 2001, 2007, 2046, 5023, 10974, 65534, 65535. The sorting subprogram must be called from your main program in response to user input. The user should be prompted to choose an array (1 or 2) and then to enter a 16-bit value to search for. (Values outside the range of 1- 2 for the array number or 0-65535 for the search value should be rejected.) After the user input is accepted and verified, the corresponding array starting offset and length as well as the search value should be passed to the search procedure. After the procedure completes, the main program must output to the screen the message "The value being searched for was not found" or "The value being searched for was found at offset offset filled in), as appropriate. As an example, if the user chose to search Array 1 and entered the value 30, your program would display the message: The value being searched for was not found. But, if the user chose to search Array 2 and entered the value 17 (and if Array 2 happened to start at offset 00404020 hexadecimal in memory), your program would display the message: The value being searched for was found at offset 00404026h. When your program is working, test it for both arrays using several values (some present and some not). Capture screen shots of each run. Also have the instructor verify its operation and sign in the space below h" (with the correct hexadecimal Write an Intel x86 assembly language program that will search arrays of unsigned word (16-bit) integers which have previously been sorted into ascending order to determine whether a supplied value is in a given array. Your program must make use of a searching procedure that does the following: Search (using a binary search algorithm) an array of n unsigned word integers (that has already been sorted into ascending numerical order) starting at address m, for the presence of a particular item i. The number of array elements n, the array starting offset m, and the value to search for i, must be passed to the subprogram in registers. (No other information may be passed into or used by the search procedure, nor may it refer by name to the array being searched.) If the supplied value matches any element of the array being searched, the memory offset of the matching element must be returned to the calling program in a register. If the supplied value does not match any of the array elements, a value of all ones (FFFF or FFFFFFFF hexadecimal, as appropriate) must be returned in the designated register instead. Your program must use assembler directives to define two arrays (one of 16 elements and one of 25 elements) and initialize them to contain the following data, respectively: Array 1 initial contents: 0, 1, 4,12, 20, 21, 35, 65, 123, 127, 128, 211,1000, 2006,14111, 60000. Array 2 initial contents: 2, 7,15,17, 72, 73, 74, 100, 122, 130, 146, 300, 543, 655, 1024, 1066, 1961, 2000, 2001, 2007, 2046, 5023, 10974, 65534, 65535. The sorting subprogram must be called from your main program in response to user input. The user should be prompted to choose an array (1 or 2) and then to enter a 16-bit value to search for. (Values outside the range of 1- 2 for the array number or 0-65535 for the search value should be rejected.) After the user input is accepted and verified, the corresponding array starting offset and length as well as the search value should be passed to the search procedure. After the procedure completes, the main program must output to the screen the message "The value being searched for was not found" or "The value being searched for was found at offset offset filled in), as appropriate. As an example, if the user chose to search Array 1 and entered the value 30, your program would display the message: The value being searched for was not found. But, if the user chose to search Array 2 and entered the value 17 (and if Array 2 happened to start at offset 00404020 hexadecimal in memory), your program would display the message: The value being searched for was found at offset 00404026h. When your program is working, test it for both arrays using several values (some present and some not). Capture screen shots of each run. Also have the instructor verify its operation and sign in the space below h" (with the correct hexadecimal

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions