0% found this document useful (0 votes)
4 views5 pages

Mni 2

This document is an assembly language program designed to search for a specific number in an array of ten numbers. It includes procedures for inserting numbers into the array and searching for the specified number, with messages indicating whether the number was found. The program is structured with defined sections for data, code, and procedures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Mni 2

This document is an assembly language program designed to search for a specific number in an array of ten numbers. It includes procedures for inserting numbers into the array and searching for the specified number, with messages indicating whether the number was found. The program is structured with defined sections for data, code, and procedures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

ASSIGNMENT 2

Submitted To:
Dr Shahroon Saleem
Submitted BY:
Muhammad Talha Iqbal
Registration No:
22-CP-39
Section:
Alpha

University of Engineering and Technology,


Taxila
CODE
.model small

.stack 100h

.data

array db 10 dup(0) ; array to store 10 numbers

search_num db 5 ; number to search

found_msg db "Number found at offset: $"

not_found_msg db "Number not found.$"

.code

main proc

mov ax, @data

mov ds, ax

call PROC_INS ; insert numbers into array

mov bx, offset array ; set BX to point to the beginning of the array

mov bl, search_num ; load search number into BL

call PROC_SEARCH ; search for the number

; print result

mov ah, 09h


mov dx, offset found_msg

int 21h

mov dx, offset array

add dx, bp ; BP contains the offset address of the number

mov ah, 02h

int 21h

jmp exit

PROC_INS proc

mov cx, 10 ; counter for 10 numbers

mov si, 1500h ; star ng address for inser on

insert_loop:

mov al, cl ; load number into AL

mov [si], al ; insert number into memory at SI

inc si ; move to next memory loca on

loop insert_loop

ret

PROC_INS endp

PROC_SEARCH proc
mov cx, 10 ; counter for 10 numbers

mov bp, 0 ; ini alize BP to 0

search_loop:

cmp bl, [bx] ; compare search number with current array element

je found ; if equal, jump to found label

inc bx ; move to next array element

inc bp ; increment BP (offset address)

loop search_loop

; If not found, BP will s ll be 0

jmp exit_search

found:

ret

exit_search:

ret

PROC_SEARCH endp

exit:

mov ax, 4c00h

int 21h
main endp

end main

You might also like