8086 Assembly Program to Find Smallest Number from Given Numbers

data segment
STRING1 DB 08h,14h,05h,0Fh,09h
res db ?
data ends

code segment
assume cs:code, ds:data
start: mov ax, data
mov ds, ax
mov cx, 04h

mov bl, 79h
LEA SI, STRING1
up:
mov al, [SI]
cmp al, bl
jge nxt
mov bl, al
nxt:
inc si
dec cx
jnz up

mov res,bl
int 3
code ends
end start

Output

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

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

  50836 + 450860 Bytes symbol space free

      0 Warning Errors
      0 Severe  Errors

C:\TASM>link smallest.obj

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

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

C:\TASM>debug smallest.exe
-g

AX=0B0F  BX=0005  CX=0000  DX=0000  SP=0000  BP=0000  SI=0004  DI=0000
DS=0B37  ES=0B27  SS=0B37  CS=0B38  IP=001E   NV UP EI PL ZR NA PE NC
0B38:001E CC            INT     3
-d 0b37:0000
0B37:0000  08 14 05 0F 09 05 00 00-00 00 00 00 00 00 00 00   ................
0B37:0010  B8 37 0B 8E D8 B9 04 00-B3 79 8D 36 00 00 8A 04   .7.......y.6....
0B37:0020  3A C3 7D 02 8A D8 46 49-75 F4 88 1E 05 00 CC FC   :.}...FIu.......
0B37:0030  FE C4 9E FA FE 26 8A 47-0C 2A E4 40 50 8B C3 05   .....&.G.*.@P...
0B37:0040  0C 00 52 50 E8 19 46 83-C4 04 50 8D 86 00 FF 50   ..RP..F...P....P
0B37:0050  E8 6F 70 83 C4 06 B8 CD-05 50 8D 86 00 FF 50 E8   .op......P....P.
0B37:0060  CA 0C 83 C4 04 B8 FF FF-50 8D 86 00 FF 50 8D 46   ........P....P.F
0B37:0070  80 50 E8 4D FA 83 C4 06-0A C0 75 03 E9 7B FF 5E   .P.M......u..{.^
-q

Leave a Reply

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