0

Create an assembly language program that switches the case of each letter in a string variable. eg .

mystring BYTE "Hello World",0

output:

hELLO wORLD

I tried the following code, but this convert all characters to upper case. I dnt know how to convert upper case to lower and vise versa in a string

.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword

.data

    mystring BYTE "Hello World",0

.code
main proc

mov ecx,LENGTHOF mystring
mov esi,OFFSET mystring

L1:
and  BYTE PTR \[esi\],11011111b  
inc  esi
loop L1

    invoke ExitProcess,0

main endp
end main
Prabhjot
  • 3
  • 4
  • 2
    You can use `xor` to flip the case bit unconditonally. Depending on your assignment you might need to check if it's a letter first. – Jester Oct 30 '22 at 11:44
  • How to check whether it is a uppercase or lowercase – Prabhjot Oct 30 '22 at 11:47
  • You have to check that the byte value is >= 'A' and <= 'Z' (capital letter) or >= 'a' and <= 'z' (small letter). – ecm Oct 30 '22 at 12:46

0 Answers0