Code:
; Program to find smallest number in the array using Macro
.MODEL SMALL
.STACK 100H
SMALL_W MACRO ARRAY , LENGTH , SMALLEST
LOCAL UP
LOCAL NEXT
PUSH AX
PUSH CX
PUSH SI
MOV CL , LENGTH
MOV SI , OFFSET ARRAY
MOV AX , [SI]
DEC CL
UP:
ADD SI , 2
CMP AX , [SI]
JC NEXT
MOV AX , [SI]
NEXT:
DEC CL
JNZ UP
MOV SMALLEST , AX
POP SI
POP CX
ENDM
.DATA
LIST_1 DW 12H,19,98H,54H,73H
LIST_2 DW 65H,75H,85H,06H,45H
COUNT DB 5
SMALL_1 DW ?
SMALL_2 DW ?
.CODE
MOV AX , @DATA
MOV DS , AX
SMALL_W LIST_1 , COUNT , SMALL_1
;SMALLEST FROM LIST 1
MOV AX , SMALL_1
AAM ; INSTRUCTION DIVIDES BY 10
MOV BH , AL
MOV DL , AH
ADD DL , 48
MOV AH , 02
INT 21H
MOV DH , 00
MOV DL , BH
ADD DL , 48
MOV AH , 02
INT 21H
; New Line
MOV AH , 2
MOV DL , 0DH ;CARGE RETURN
INT 21H
MOV DL , 0AH ;LINE FEED
INT 21H
SMALL_W LIST_2 , COUNT , SMALL_2
;SMALLEST FROM LIST 2
MOV AX , SMALL_2
AAM ; INSTRUCTION DIVIDES BY 10
MOV BH , AL
MOV DL , AH
ADD DL , 48
MOV AH , 02
INT 21H
MOV DH , 00
MOV DL , BH
ADD DL , 48
MOV AH , 02
INT 21H
MOV AH , 4CH ; Service routine for exit
INT 21H
END
Output:
; Program to find smallest number in the array using Macro
.MODEL SMALL
.STACK 100H
SMALL_W MACRO ARRAY , LENGTH , SMALLEST
LOCAL UP
LOCAL NEXT
PUSH AX
PUSH CX
PUSH SI
MOV CL , LENGTH
MOV SI , OFFSET ARRAY
MOV AX , [SI]
DEC CL
UP:
ADD SI , 2
CMP AX , [SI]
JC NEXT
MOV AX , [SI]
NEXT:
DEC CL
JNZ UP
MOV SMALLEST , AX
POP SI
POP CX
ENDM
.DATA
LIST_1 DW 12H,19,98H,54H,73H
LIST_2 DW 65H,75H,85H,06H,45H
COUNT DB 5
SMALL_1 DW ?
SMALL_2 DW ?
.CODE
MOV AX , @DATA
MOV DS , AX
SMALL_W LIST_1 , COUNT , SMALL_1
;SMALLEST FROM LIST 1
MOV AX , SMALL_1
AAM ; INSTRUCTION DIVIDES BY 10
MOV BH , AL
MOV DL , AH
ADD DL , 48
MOV AH , 02
INT 21H
MOV DH , 00
MOV DL , BH
ADD DL , 48
MOV AH , 02
INT 21H
; New Line
MOV AH , 2
MOV DL , 0DH ;CARGE RETURN
INT 21H
MOV DL , 0AH ;LINE FEED
INT 21H
SMALL_W LIST_2 , COUNT , SMALL_2
;SMALLEST FROM LIST 2
MOV AX , SMALL_2
AAM ; INSTRUCTION DIVIDES BY 10
MOV BH , AL
MOV DL , AH
ADD DL , 48
MOV AH , 02
INT 21H
MOV DH , 00
MOV DL , BH
ADD DL , 48
MOV AH , 02
INT 21H
MOV AH , 4CH ; Service routine for exit
INT 21H
END
Output: