-
Notifications
You must be signed in to change notification settings - Fork 1
/
32. FIRST CAPITAL & LAST CAPITAL.asm
79 lines (60 loc) · 1.67 KB
/
32. FIRST CAPITAL & LAST CAPITAL.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
79
.MODEL SMALL
.STACK 100H
.DATA
PROMPT DB 'TYPE A LINE OF TEXT',0DH,0AH,'$'
NO_CAPMSG DB 0DH,0AH,'NO CAPITALS $'
CAP_MSG DB 0DH,0AH,'FIRST CAPITAL = '
FIRST DB '['
DB 0DH,0AH
DB 'LAST CAPITAL = '
LAST DB '@ $'
.CODE
MAIN PROC
;INITIALIZE DS
MOV AX,@DATA
MOV DS,AX
;DISPLAY OPENING MESSAGE
MOV AH,9
LEA DX,PROMPT
INT 21H
;READ CHARACTER FUNCTION
MOV AH,1
INT 21H
;WHILE CHARACTER IS NOT A CARRIAGE RETURN
WHILE_:
CMP AL,0DH ;IF CARRIAGE_RETURN
JE EXIT_WHILE ; YES, EXIT LOOP
;IF CHARACTER IS A CAPITAL LETTER
CMP AL,'A' ;IS CHARACTER CAPITAL?
JNGE END_IF ;IF NOT,END IF
CMP AL,'Z' ;IS CHARACTER CAPITAL AND BELOW 'Z'
JNLE END_IF ;IF NOT, END IF
;THEN
CMP AL,FIRST ; IS CHAR<FIRST
JNL CHECK_LAST ;IF NOT THEN CHECK FOR LAST CHARACTER
;THEN
MOV FIRST,AL ;FIRST = CHAR
CHECK_LAST:
CMP AL,LAST ;IS CHAR>LAST
JNG END_IF
;THEN
MOV LAST,AL ;LAST = AL
END_IF:
INT 21H
JMP WHILE_
EXIT_WHILE:
MOV AH,9
;IF NO CAPITALS WERE
CMP FIRST,'['
JNE CAPITAL
;THEN
LEA DX,NO_CAPMSG ;NO CAPITALS
JMP DISPLAY
CAPITAL:
LEA DX,CAP_MSG ;CAPITAL MESSAGE
DISPLAY:
INT 21H
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN