0% found this document useful (0 votes)
51 views5 pages

Ass 9

The assembly program: 1. Displays "?" and reads two characters from the user. 2. Prints the characters in alphabetical order on the next line. 3. Continues prompting the user for a hexadecimal digit, converts it to decimal and displays the output. 4. Asks the user if they want to continue and repeats if they enter Y/y, otherwise ends the program.

Uploaded by

sameer khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views5 pages

Ass 9

The assembly program: 1. Displays "?" and reads two characters from the user. 2. Prints the characters in alphabetical order on the next line. 3. Continues prompting the user for a hexadecimal digit, converts it to decimal and displays the output. 4. Asks the user if they want to continue and repeats if they enter Y/y, otherwise ends the program.

Uploaded by

sameer khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Question No 1: a. Write an Assembly program that display “?” at eh start.

Read two characters from


the user and display them at next line in alphabetic order.

.MODEL SMALL
.STACK 100H
.DATA
st DB " first letter : $\"
stt DB " second letter : $\"
sttt DB "The given letters in alphabetical order are : $\"
n DB 13D,10D, "$\"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

MOV AH, 2
MOV DL, "?"
INT 21H

MOV AH, 9

LEA DX, n
INT 21H

LEA DX, st
INT 21H

MOV AH, 1
INT 21H

MOV BL, AL

MOV AH, 9

LEA DX, n
INT 21H

LEA DX, stt


INT 21H

MOV AH, 1
INT 21H

MOV BH, AL

MOV AH, 9

LEA DX, n
INT 21H

LEA DX, sttt


INT 21H

MOV AH, 2

CMP BL, BH

JAE @GREATER
MOV DL, BL
INT 21H

MOV DL, BH
INT 21H
JMP @END

@GREATER:
MOV DL, BH
INT 21H

MOV DL, BL
INT 21H

@END:

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN
b. Write an Assembly program that takes hex decimal from (0 … to … 9) and (A…. to,,,,,, F) from the
user, and at next line in decimal. Program prompt the user for Continue??(Y/y) if user enter Y/y then
it repeats if other then Y/y then program got end.

.MODEL SMALL
.STACK 100H
.DATA
MSG DB 'TRY AGAIN.$'
aa DB 'ENTER A HEX DIGIT "0"..."9" OR "A".."F": $'
bb DB 10D,13D,'OUTPUT: $'
input DB 10D,13D,'DO YOU WANT ANOTHER INPUT: $'
.CODE
MAIN PROC

MOV AX,@DATA
MOV DS,AX

TOP:
MOV AH,9
LEA DX,aa
INT 21H

MOV AH,1
INT 21H
MOV BL,AL

CMP BL,30H
JL TRY_MSG

CMP BL,46H
JG TRY_MSG

CMP BL,39H
JLE DIGIT

MOV AH,9
LEA DX,bb
INT 21H

SUB BL,11H

MOV AH,2
MOV DL,31H
INT 21H
MOV DL,BL
INT 21H
AGAIN:
MOV AH,9
LEA DX,input
INT 21H

MOV AH,1
INT 21H
MOV BH,AL
MOV AH,2
MOV DL,10D
INT 21H
MOV DL,13D
INT 21H
CMP BH,'Y'
JE TOP
CMP BH,'y'
JE TOP
JMP END_
DIGIT:
MOV AH,9
LEA DX,bb
INT 21H

MOV AH,2
MOV DL,BL
INT 21H

JMP AGAIN
TRY_MSG:
MOV AH,9
LEA DX,MSG
INT 21H
JMP TOP
END_:

MOV AH,4CH
INT 21H

MAIN ENDP
END MAIN

You might also like