I am trying to write an assembly program on emu8086 to convert upper to lower and vice versa user inputted string but it's not changing any character of the string:
.data
buffer db 10,?, 10 dup('')
.code
; Read the input
mov ah, 0ah int 21h
mov si,2
mov ah,0 mov al, [si]
;convert
start:
cmp al, 0
je show
; Lowercase to uppercase
cmp al, 'a'
jl upper
cmp al, 'z'
jg upper
sub al, 32
jmp check
upper: cmp al, 'A'
jl next_bit
cmp al, 'Z'
jg next_bit
add al, 32
jmp check
check:
mov [si], al jmp next_bit
;incrementing si register to get the next character
next_bit: inc si
mov al,[si]
jmp start
;display result
show:
mov si,2
lea dx,si
mov ah, 9
int 21h
jmp end
end: mov ah, 4ch
int 21h
mov si, offset bufferis wrong. The text starts atbuffer+2.cmp al, 0is wrong. Yourbufferis not zero initialized and you should use the returned byte count anyway.; Uppercase to lowercaseblock is unreachable.next_bitis a misnomer. You probably meantnext_byte.lea dx, siis wrong. You have already incrementedsito point past the string. You should reloaddxwithbuffer+2. (Should be a syntax error too.)$so int21/09 can not print it as is.jmp checkis not wrong :) But it's certainly useless jumping to the next line.