-
Notifications
You must be signed in to change notification settings - Fork 26
/
ASCII_EQUIVALENT.asm
59 lines (44 loc) · 1.3 KB
/
ASCII_EQUIVALENT.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
;#############################################################################################################
;## Assembly Program to read any AlphaNumeric character and display it's equivalent (Hexadecimal)ASCII code
;## Author : euhidaman
;#############################################################################################################
.model small
print MACRO msg
LEA DX, msg
mov ah, 09h
int 21h
ENDM
.data
msg1 db 10,13,"Enter any AlphaNumeric Character = $"
msg2 db 10,13,"ASCII equivalent(hexa) is = $"
res db ?,?
.code
mov ax,@data
mov ds,ax
print msg1
mov AH,01h ;read single character
int 21h
mov BL, AL ;copy character for reserving
mov CL, 4 ;counter for shift
SHR AL, CL ;shift right 4 times for HIGHER nibble
CMP AL, 0AH ;check if greater thn 0Ah, for proper hexa ASCII number
JB digit_label
ADD AL,7 ;add 7, if AL>09
digit_label : ADD AL,30h
MOV res, AL
AND BL, 0Fh ;Masking for LOWER nibble
CMP BL, 0Ah
JB digit1_label
ADD BL,7
digit1_label : ADD BL, 30h
mov res+1, BL
print msg2
MOV DL, res
MOV AH, 02h
int 21h
mov DL, res+1
mov AH, 02h
int 21h
mov AH, 4ch
int 21h
END