This project is a simple assembly language program that searches for a user-entered number in a predefined array. The program is written in x86 assembly language and runs on a DOS environment. The purpose is to demonstrate basic input/output operations and array processing in assembly language.
- Prompts the user to enter a number.
- Searches for the entered number in a predefined array.
- Displays the index of the number if it is found.
- Displays a message indicating the number is not present if it is not found.
-
Initialization:
- Set up the data segment and initialize pointers and registers.
-
User Input:
- Prompt the user to enter a number.
- Read the user's input and store it in the
num
variable.
-
Search Operation:
- Traverse through the predefined array (
myarr
). - Compare each element with the user-entered number.
- If the number is found, jump to the
exit
label to display the index. - If the number is not found by the end of the array, jump to the
exitt
label to display a not-found message.
- Traverse through the predefined array (
-
Output:
- Display the index of the number if found.
- Display a message indicating the number is not present if not found.
-
Exit:
- Terminate the program.
-
Data Segment:
myarr
: An array of numbers to be searched.num
: The number input by the user.index
: To store the current index during the search.isfound
: A flag to indicate if the number was found.enter
,found
,notfound
: Strings for user interaction.
-
Code Segment:
- Uses
int 21h
for DOS interrupt services to handle input and output. - Utilizes loop constructs and conditional jumps to search the array.
- Uses
-
Compile:
- Assemble the code using an assembler such as MASM or TASM.
-
Run:
- Execute the compiled program in a DOS environment or DOS emulator.
-
Enter a Number:
- Follow the on-screen prompts to enter a number between 0 and 9.
-
View Results:
- The program will display whether the number was found and its index or indicate that the number is not present.
Enter the number: 5
number is present in the array at index 4
- Ensure that you are using a DOS environment or emulator like DOSBox to run this assembly program.
- The code is designed for educational purposes and may require modifications for different environments or more complex use cases.
This project is licensed under the MIT License. See the LICENSE file for more details.