Question: Write a LC 3 - program to do a linear search for a key in an unsorted array. The number to search can be found

Write a LC3-program to do a linear search for a key in an unsorted array. The number to search can be found at label key
and should be stored in register R1. The number of elements in the array, found at label n
should be loaded into register R2, and the address of (the start of) the array, given by label data
, should be stored in register R3. Your program should determine the position of the key in the array ( which is a value between 0 to n1) if it exists and store this position in register R0. If the key is not in the array, store -1 in register R0.
You can use the following of LC-3 code as a starting point for your program. When handing in, use the data provided in the template. You DO NOT need to validate your inputs (that is, assume the inputs are valid)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!