I have been having problems on how can I revise or if someone could me a code on emu8086 on how to convert uppercase string into lowercase..the code below converts lowercase into uppercase..how can i revise it? Thanks in advance


org 100h


.model small
.stack 200
.data
msg db 'enter a string in small letter: ','$'
msg1 db 'this is what you entered in capital: ','$'
string db 20, 22 dup('?')

crlf db 0Dh,0Ah, '$' ; new line code.

.code
.startup
lea dx, msg
mov ah, 09h
int 21h

lea dx, string

mov ah, 0ah
int 21h

mov bx, dx
mov ah, 0
mov al, ds:[bx+1]
add bx, ax ; point to end of string.

mov byte ptr [bx+2], '$'

lea dx, crlf ;new line
mov ah, 09h
int 21h


lea bx, string
mov ch, 0
mov cl, [bx+1]
add bx, 2

upper_case:

and byte ptr [bx], 11011111b

inc bx ; increment
loop upper_case


lea dx, msg1
mov ah, 09h
int 21h

lea dx, string+2
mov ah, 09h
int 21h

ret

end

Recommended Answers

All 9 Replies

and after you've edited for readability, maybe post a few ideas of your own on how you would solve this problem because it is after all beyond simple.

Clue: Do the opposite of what you did to convert to uppercase!

can anyone help me do the oposite of that code. Entering a lowercase string then the program converts it into uppercase..the opposite of the program it self

'A' XOR 32 = 'a'
'a' XOR 32 = 'A'
Simple innit?

'A' XOR 32 = 'a'
'a' XOR 32 = 'A'
Simple innit?

Where am I suppose to add that code?

Where am I suppose to add that code?

In your upper_case loop or byte ptr [bx], 32 I've choosen OR only because if the character was already lower case there would be no change, XOR on the other hand would change lower to upper and upper to lower thus acting like a toggle switch.

Thank you! Thank you! It works and it rocks! Thanks! by the way, why is it 32? i have tried that code or

byte ptr [bx], 11011111b

..but it did not work, why is that?

> why is it 32?
What is 'a' - 'A'

Write out a few letters in binary.

>>why is it 32

Look at any standard ASCII chart and you will see that the letter 'A' = 65 and 'a' = 97. 32 is the difference between them. Subtract 32 from any lower-case letter and you will get the upper-case letter.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.