8086 Assembly Program to Search an Element in an Array

DATA SEGMENT
STRING1 DB 11H,22H,33H,44H,55H
MSG1 DB "FOUND$"
MSG2 DB "NOT FOUND$"
SE DB 33H
DATA ENDS

PRINT MACRO MSG
MOV AH, 09H
LEA DX, MSG
INT 21H
INT 3
ENDM

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV AL, SE
LEA SI, STRING1
MOV CX, 04H

UP:
MOV BL,[SI]
CMP AL, BL
JZ FO
INC SI
DEC CX
JNZ UP
PRINT MSG2
JMP END1

FO:
PRINT MSG1

END1:
INT 3
CODE ENDS
END START

Output

C:\TASM>masm se.asm
Microsoft (R) Macro Assembler Version 5.00
Copyright (C) Microsoft Corp 1981-1985, 1987.  All rights reserved.

Object filename [se.OBJ]:
Source listing  [NUL.LST]:
Cross-reference [NUL.CRF]:

  50346 + 450310 Bytes symbol space free

      0 Warning Errors
      0 Severe  Errors

C:\TASM>link se.obj

Microsoft (R) Overlay Linker  Version 3.60
Copyright (C) Microsoft Corp 1983-1987.  All rights reserved.

Run File [SE.EXE]:
List File [NUL.MAP]:
Libraries [.LIB]:
LINK : warning L4021: no stack segment

C:\TASM>debug se.exe
-G
FOUND
AX=0924  BX=0033  CX=0002  DX=0005  SP=0000  BP=0000  SI=0002  DI=0000
DS=0B97  ES=0B87  SS=0B97  CS=0B99  IP=002D   NV UP EI PL ZR NA PE NC
0B99:002D CC            INT     3
-Q

Leave a Reply

Your email address will not be published. Required fields are marked *