.model
small
.stack
100h
.data
buffer
db 101 dup(0)
quitstring db "quit"
.code
print_literal MACRO
lit
local string, end1
push
ax
push
dx
push
ds
mov ax, cs
mov ds, ax
mov
dx, offset string
call output_string
pop
ds
pop
dx
pop
ax
jmp end1
string db lit,'$'
end1:
ENDM
readstring MACRO str
push dx
push ax
mov dx, offset str
mov
al, 100
call input_string
pop ax
pop dx
ENDM
printstring MACRO str
push dx
mov dx, offset str
call output_string
pop dx
ENDM
crlf MACRO
push ax
push
dx
mov
ah, 02H
mov
dl, 0DH
int
21H
mov
dl, 0AH
int
21H
pop
dx
pop
ax
ENDM
output_string PROC
NEAR
push
ax
push
dx
mov
ah, 09h
int
21h
pop
dx
pop
ax
ret
output_string ENDP
input_string PROC
NEAR
push
dx
push
cx
push
si
push
di
push
es
push
ds
mov
di, dx
mov
cx, ds
mov
es, cx
mov
cx, cs
mov
ds, cx
mov
cs:formatted_buffer[0], al
mov
dx, offset formatted_buffer
mov
ah, 0Ah
int
21h
mov
si, offset formatted_buffer
add
si, 2
mov
cl, cs:formatted_buffer[1]
mov
ch, 0
rep
movsb
mov
byte ptr es:[di], '$'
mov
al, cs:formatted_buffer[1]
pop
ds
pop
es
pop di
pop
si
pop
cx
pop
dx
ret
formatted_buffer db
257 dup(0)
input_string ENDP
quit PROC
NEAR
mov
ah, 4Ch
int
21h
quit ENDP
.startup
mov ax, @data
mov ds, ax
mov es, ax
print_literal "Input a string: "
readstring buffer
crlf
print_literal "The string you typed in all lowercase
is: "
main1:
mov ah, 6
mov dl, 0ffH
int 21H
je main1
cmp al, 3
je main2
l1:
lodsb
add al, 20h
stosb
loop l1
skip:
mov dl, al
int 21h
jmp main1
main2:
.exit
.exit
END