-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoft3.asm
51 lines (41 loc) · 782 Bytes
/
soft3.asm
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
.MODEL SMALL
.DATA
A DW 1122H,2345H,3333H,4455H,6666H
LEN DW ($-A)/2
SRCH EQU 2345H
SUCMSG DB 10,13,'ELEMENT FOUND AT POSITION: '
RES DB ?,'$'
FAILMSG DB 10,13,'ELEMENT NOT FOUND $'
.CODE
MOV AX,@DATA
MOV DS,AX
MOV BX,1
MOV CX,SRCH
MOV DX,LEN
AGAIN: CMP BX,DX
JA FAILURE
MOV AX,BX
ADD AX,DX
SHR AX,1
MOV SI,AX
DEC SI
ADD SI,SI
CMP CX,A[SI]
JAE BIGGER
DEC AX
MOV DX,AX
JMP AGAIN
BIGGER: JE SUCCESS
INC AX
MOV BX,AX
JMP AGAIN
SUCCESS: MOV AL, '0'
MOV RES, AL
LEA DX,SUCMSG
JMP EXIT
FAILURE: LEA DX, FAILMSG
EXIT: MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
END