SoFunction
Updated on 2025-03-04

Use assembly to implement upper and lower case conversion of strings

Using assembly programming, you can directly access the data in memory and perform related operations on the data. Now you need to use assembly instructions and or to convert the string data into case. As shown in the following example, convert BaSiC to uppercase and iNforMaTiOn to lowercase.

example:

assume cs:codesg,ds:datasg

datasg segment
 db 'BaSiC'
 db 'iNforMaTiOn'
datasg ends

codesg segment
 start: mov ax,datasg
  mov ds,ax
  
  mov cx,5
  mov bx,0
  
 s1: mov al,ds:[bx]
  and al,11011111b
  mov ds:[bx],al
  inc bx
  loop s1
 
  mov cx,11
  mov bx,5
  
 s2: mov al,ds:[bx]
  or al,00100000b
  mov ds:[bx],al
  inc bx
  loop s2
  
  mov ax,4c00h
  int 21h

codesg ends

end start

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.