; convert small letters to capital AND vice-versa
mov ah,0ah
lea dx,parameter
int 21h
mov ah,02
mov dl,0ah
int 21h
mov dl,0dh
int 21h
; initialize
lea si, input
xor cx, cx
mov cl, [actlen]
; We wish to check if character is a letter
; if yes, capitalize small letters and vice-versa
; if no, copy character
invert:
mov al, [si]
cmp al, 122
ja skip
cmp al, 96
ja capital
cmp al, 90
ja skip
cmp al, 63
jb skip
add al, 32
jmp store
capital:
sub al, 32
store:
mov [si], al
skip:
inc si
loop invert
mov ah, 09
lea dx, input
int 21h
int 20h
parameter label byte
maxlen db 0FF
actlen db ?
input db 0FF dup(’$')
; reverse string
mov ah,0ah
lea dx,parameter
int 21h
mov ah,02
mov dl,0ah
int 21h
mov dl,0dh
int 21h
; initialize
xor cx, cx ; zero out cx
lea si, origstring ; si = inputted string
mov cl, [actlen] ; cl = length of inputted string
dec cl ; since string starts from 0 to cl-1
lea di, revstring ; di = empty
add di, cx
reverse:
mov al, [si] ; get character
mov [di], al ; copy to di at ‘cl-1′th position
dec di
inc si
cmp al, ‘$’ ; means end of string
jne reverse
mov ah, 09
lea dx, revstring
int 21h
int 20h
parameter label byte
maxlen db 0FF
actlen db ?
origstring db 0FF dup(’$')
revstring db 0FF dup (’$')