-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBIN_SRCH.ASM
More file actions
53 lines (50 loc) · 782 Bytes
/
BIN_SRCH.ASM
File metadata and controls
53 lines (50 loc) · 782 Bytes
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
assume cs : code ,ds : data
data segment
a db 10h, 12h, 14h, 17h, 20h
n db n-a
key db 10h
msg1 db "Key not found $"
msg2 db "Key found at "
pos db ?, "$"
data ends
code segment
start:
mov ax,data
mov ds,ax
mov al,0
mov dl,n
dec dl
again:
cmp al, dl
ja failed
mov cl,al
add al,dl
shr al,1
mov ah, 00h
mov si,ax
mov bl, [si]
cmp bl, key
jae above
inc al
jmp again
above:
je success
dec al
mov dl, al
mov al, cl
jmp again
failed:
lea dx, msg1
jmp display
success:
inc al
add al, 30h
mov pos, al
lea dx, msg2
display:
mov ah,9h
int 21h
mov ah,4ch
int 21h
code ends
end start