-
Notifications
You must be signed in to change notification settings - Fork 1
/
2. Letter Conversion.asm
78 lines (56 loc) · 1.25 KB
/
2. Letter Conversion.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
; GIVEN A LOWERCASE LETTER
; PRINT THE LOWERCASE LETTER OF THE LETTER BEFORE THE UPPERCASE
; SUPPOSE, IF B IS GIVEN PRINT 'a'
; ALSO PRINT IT'S 1'S COMPLEMENT
.MODEL SMALL
.STACK 100H
.DATA
CLR EQU 0DH
RLF EQU 0AH
MSG1 DB 'ENTER A UPPER CASE LETTER: $'
MSG2 DB CLR, RLF, 'IN LOWER CASE IT IS: $'
MSG3 DB CLR, RLF, 'ONE', 27H, 'S COMPLEMENT IS: $'
CHAR DB ?
COMP DB ?
.CODE
MAIN PROC
;INITIALIZE DS
MOV AX, @DATA
MOV DS, AX
;DISPLAY MESSAGE FOR USER
LEA DX, MSG1
MOV AH, 9
INT 21H
;INPUT A UPPERCASE CHARACTER
MOV AH, 1
INT 21H
;CONVERT TO LOWERCASE
ADD AL, 1FH
MOV CHAR, AL
;CONVERT TO ONE'S COMPLEMENT
;1'S COMPLEMENT = 2'S COMPLEMENT - 1
SUB AL, 1FH
NEG AL
SUB AL, 1
MOV COMP, AL
;DISPLAY THE MESSAGE BEFORE SHOWING LOWERCASE LETTER
LEA DX, MSG2
MOV AH, 9
INT 21H
;DISPLAY THE LOWERCASE LETTER
MOV AH, 2
MOV DL, CHAR
INT 21H
;DISPLAY THE MESSAGE BEFORE SHOWING ONE'S COMPLEMENT
LEA DX, MSG3
MOV AH, 9
INT 21H
;DISPLAY ONE'S COMPLEMENT
MOV AH, 2
MOV DL, COMP
INT 21H
;DOX exit
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN