forked from mohitarora3/assembly_programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinear_search.asm
More file actions
54 lines (35 loc) · 1.2 KB
/
linear_search.asm
File metadata and controls
54 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
;........................................................................
data segment
array db 1,2,3,4,5
ele db 2 ;ele variable stores the element to be searched
FOUND db 'ELEMENT FOUND $'
NOT_FOUND db 'ELEMENT NOT FOUND $'
data ends
;...........................................................................
;............................................................................
code segment
assume ds:data,cs:code
start:
mov ax,data
mov ds,ax
xor ax,ax ;initializing ax register with value 0
mov cx,5
mov bl,2
mov si,-1
next:
inc si
mov al,array[si]
cmp al,ele
je present ;if search is successful
loop next
mov dx,offset NOT_FOUND ;if element is not present in arrray
mov ah,9
int 21h
jmp exit
present: mov dx,offset FOUND
mov ah,9
int 21h
exit:hlt
code ends
end start
;.............................................................