-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalternate_case.asm
More file actions
86 lines (72 loc) · 1.74 KB
/
alternate_case.asm
File metadata and controls
86 lines (72 loc) · 1.74 KB
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
80
81
82
83
84
85
86
;WAP in 8086 to read word from user and display all the alphabets in alternate case
;(first alphabet in uppercase, second alphabet in lower case , third alphabet in
;upper case and so on) in clear screen.
.model small
.stack 64
.data
MAXLEN DB 255
ACTLEN DB ?
INPUT DB 255 DUP('$')
prompt db 'Enter a word: $'
.code
main proc far
mov ax, @data
mov ds, ax
; Prompt user
mov ah, 09h
lea dx, prompt
int 21h
;string input
mov ah, 0ah
lea dx, MAXLEN
int 21h
;clear screen
MOV AX,0600H;REQ TO SCROLL
MOV BH,61H ;BLUE ON BROWN FOR ATTRIBUT ON PIXEL
MOV CX,0000H
MOV DX,1950H
INT 10h
;Cursor Reset
MOV AH, 02h ; Function 02h: Set cursor position
MOV BH, 00h ; Video page 0
MOV DX, 0000h ; Row 0, column 0
INT 10h
;loop counter
mov ch, 0
mov cl, actlen
;upper and lower count
lea SI, INPUT
MOV BL, 1 ;uppercase flag
l1:
mov al, [si]
cmp al, 'A'
JL print
cmp al, 'z'
JG print
cmp al, 'Z'
JG check_lower
cmp bl, 1
jz print
add al, 32
jmp print
check_lower:
cmp al, 'a'
JL print
cmp bl, 0
jz print
sub al, 32
print:
mov ah, 02h
mov dl, al
int 21h
cmp bl, 1 ; uppercase flag toggle
jz skip
mov bl, 1
jmp skip2
skip: mov bl, 0
skip2: inc si
loop l1
mov ah, 4Ch
int 21h
main endp
end