Practice Program in Assembly Language

Practice Program in Assembly Language

ORG 100H
.MODEL SMALL
.DATA
ARR DB 4 DUP(?)
ARR1 DB 4 DUP(?)
ARR2 DB 4 DUP(?)
AHSAN DB "ENTER ROLL NUMBER(4-DIGIT): ", "$"
AHSAN1 DB "ENTER COLLEAGUE ROLL NUMBER(4-DIGIT): ", "$"
AHSAN2 DB "ROLL NUMBER IS ", "$"
AHSAN3 DB " GREATER THAN COLLEAGUE'S ROLL-NUMBER", "$"
AHSAN4 DB " LESSER THAN COLLEAGUE'S ROLL-NUMBER", "$"
NewLine DB 0AH, 0DH, "$"
.CODE
LEA DX, AHSAN
MOV AH, 09H
INT 21H
MOV CX, 4
MOV SI, 0
INPUT_1:
MOV AH, 1
INT 21H
MOV ARR[SI], AL
INC SI
LOOP INPUT_1
LEA DX, NewLine
MOV AH, 9 ;PRINT NEW LINE
INT 21H
LEA DX, AHSAN1
MOV AH, 9
INT 21H
MOV CX, 4
MOV BP, 0
INPUT_2:
MOV AH, 1
INT 21H
MOV ARR1[BP], AL
INC BP
LOOP INPUT_2
MOV DH, ARR[0]
CMP DH, ARR1[0]
JG FIRST
MOV BX, 0
MOV BP, 0
MOV SI, 0
MOV CX, 4
SUB_1:
MOV DH, ARR1[BX]
SUB DH, ARR[BP]
MOV ARR2[SI], DH
ADD ARR2[SI], 30H
INC BX
INC BP
INC SI
LOOP SUB_1
LEA DX, NewLine
MOV AH, 9
INT 21H
LEA DX, AHSAN2
MOV AH, 9
INT 21H
JMP SECOND
FIRST:
MOV BX, 0
MOV BP, 0
MOV SI, 0
MOV CX, 4
SUB_2:
MOV DH, ARR[BX]
SUB DH, ARR1[BP]
MOV ARR2[SI], DH
ADD ARR2[SI], 30H
INC BX
INC BP
INC SI
LOOP SUB_2
LEA DX, NewLine
MOV AH, 9
INT 21H
LEA DX, AHSAN2
MOV AH, 9
INT 21H
MOV BX, 0
MOV CX, 4
DISPLAY:
MOV DL, ARR2[BX]
MOV AH, 2
INT 21H
INC BX
LOOP DISPLAY
LEA DX, AHSAN3
MOV AH, 9
INT 21H
JMP END
SECOND:
MOV BX, 0
MOV CX, 4
DISPLAY_1:
MOV DL, [ARR2 + BX]
MOV AH, 2
INT 21H
INC BX
LOOP DISPLAY_1
LEA DX, AHSAN4
MOV AH, 9
INT 21H
END:
.EXIT
RET

Output:

output

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s