COAL
COAL
SOL:.MODEL SMALL
.STACK 100H
.DATA
PROMPT_1 DB 'Enter the first capital letter : $'
PROMPT_2 DB 'Enter the second capital letter : $'
PROMPT_3 DB 'The given capital letters in alphabetical order are : $'
NEXT_LINE DB 0DH,0AH,"$"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV AH, 2
MOV DL, "?"
INT 21H
MOV AH, 9
MOV AH, 1
INT 21H
MOV BL, AL
MOV AH, 9
MOV AH, 1
INT 21H
MOV BH, AL
MOV AH, 9
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:
.code
mov cx,127
mov bl,0
print:
mov ah,2
inc cx
cmp cx,255
ja exit
mov dx,cx
int 21h
mov dx,32d
int 21h
jmp go
go:
inc bl
cmp bl,10
je nl
jmp print
nl:
mov ah,2
mov dl,0dh
int 21h
mov dl,0ah
int 21h
mov bl,0
jmp print
exit:
QUESTION 10:
SOL: .MODEL SMALL
.STACK 100H
.DATA
PROMPT DB 'Enter a HEX digit : $'
DECIMAL DB 'The equivalent Decimal digit is : $'
CONTINUE DB 'Do you want to do it again : $'
ILLEGAL DB 'Illegal Character - Enter 0..9 or A..F : $'
TERMINATE DB 'You failed to enter a HEX DIGIT, press any key to exit. $'
NEXT_LINE DB 0DH,0AH,"$"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
@START_1:
MOV AH, 9
LEA DX, PROMPT
INT 21H
@START_2:
MOV AH, 1
INT 21H
MOV BL, AL
JMP @GREATER_THAN_NINE
@SINGAL_DIGIT:
CMP BL, "0"
JB @ILLEGAL_CHARACTER
JMP @LESS_THAN_TEN
@ILLEGAL_CHARACTER:
INC CL
CMP CL, 3
JE @TERMINATE
MOV AH, 9
JMP @START_2
@LESS_THAN_TEN:
MOV CL, 0
MOV AH, 9
MOV AH, 2
MOV DL, BL
INT 21H
JMP @CONTINUE
@GREATER_THAN_NINE:
MOV CL, 0
MOV AH, 9
MOV AH, 2
MOV DL, 31H
INT 21H
MOV DL, BL
INT 21H
@CONTINUE:
MOV AH, 9
MOV AH, 1
INT 21H
JMP @END
@JUMP:
LEA DX, NEXT_LINE
MOV AH, 9
INT 21H
INT 21H
JMP @START_1
@TERMINATE:
MOV AH, 9
MOV AH, 1
INT 21H
@END:
.code
main proc
mov ax,@data
mov ds,ax
lea dx,msg1
mov ah,9
int 21h
xor bx,bx
mov ah,1
int 21h
input:
cmp al,0dh
je exit
and al,0fh
shl bx,1
or bl,al
int 21h
jmp input
exit:
lea dx,msg2
mov ah,9
int 21h
mov cx,4
convert:
mov dl,bh
shr dl,1
shr dl,1
shr dl,1
shr dl,1
cmp dl,9
jbe num
add dl,55d
jmp display
num:
add dl,30h
display:
mov ah,2
int 21h
rcl bx,1
rcl bx,1
rcl bx,1
rcl bx,1
loop convert
main endp
end main
QUESTION 12:
SOL:.model small
.stack 100h
.data
.code
main proc
mov ax,@data
mov ds,ax
lea dx,msg1
mov ah,9
int 21h
mov ah,1
int 21h
xor bx,bx
mov cx,8
input1:
mov ah,1
int 21h
cmp al,0dh
je break
and al,0fh
shl bl,1
or bl,al
loop input1
break:
lea dx,msg1
mov ah,9
int 21h
mov cx,8
input2:
mov ah,1
int 21h
cmp al,0dh
je break2
and al,0fh
shl bh,1
or bh,al
loop input2
break2:
lea dx,msg2
mov ah,9
int 21h
sum:
add bl,bh
jnc zero
mov dl,31h
mov ah,2
int 21h
zero:
mov dl,30h
mov cx,8
print:
shl bl,1
jnc z
mov dl,31h
jmp display
z:
mov dl,30h
display:
mov ah,2
int 21h
loop print
main endp
end main