Convert Lowercase string to Uppercase string

Started by josefalarka, January 12, 2011, 12:54:53 AM

Previous topic - Next topic

josefalarka

The code below is to convert uppercase string to lowercase string from the book of Peter Abel (IBM PC Assembly Language Programming).  How to translate this code to convert lowercase to uppercase.

TITLE   A07CASE (COM)     Change uppercase to lowercase   
   .MODEL   SMALL   
   .CODE   
   ORG   100H
BEGIN:   JMP   A10MAIN
; --------------------------------------------------
CONAME   DB   'THIS STRING WILL BE CONVERTED TO UPPERCASE', '$'
; --------------------------------------------------

A10MAIN   PROC   NEAR   
   LEA   BX,CONAME+1   ;1st char to change   
   MOV   CX,15      ;No. of chars to change
A20:   
   MOV   AH,[BX]      ;Character from CONAME   
   CMP   AH,41H      ;Is it   
   JB   A30      ;  an upper   
   CMP   AH,5AH      ;  case   
   JA   A30      ;  letter?   
   XOR   AH,00100000B   ;Yes, convert   
   MOV   [BX],AH      ;Restore in CONAME
A30:   
   INC   BX      ;Set for next char   
   LOOP   A20      ;Loop 15 times            ;Done,   

   MOV   AH,09H      ;  display   
   LEA   DX,CONAME   ;  CONAME   
   INT   21H   
   MOV   AX,4C00H   ;End processing   
   INT   21HA
A10MAIN   ENDP
            END     BEGIN

dedndave

first of all - this is 16-bit code
not sure if you are aware of it - we have a 16-bit subforum (near bottom of main page)
also - it is ORG'ed at 100h - presumably to make a .COM program - in which case, the model should be .TINY
BEGIN:   JMP   A10MAIN
; --------------------------------------------------
CONAME   DB   'this string will be converted to uppercase', '$'
; --------------------------------------------------

A10MAIN   PROC   NEAR   
   LEA   BX,CONAME+1   ;1st char to change   
   MOV   CX,15      ;No. of chars to change
A20:   
   MOV   AH,[BX]      ;Character from CONAME   
   CMP   AH,61H      ;Is it       was 41h('A') - 61h = 'a'
   JB   A30      ;  a lower   
   CMP   AH,7AH      ;  case      was 5Ah('Z') - 7Ah = 'z'
   JA   A30      ;  letter?   
   XOR   AH,00100000B   ;Yes, convert   
   MOV   [BX],AH      ;Restore in CONAME
A30:   
   INC   BX      ;Set for next char   
   LOOP   A20      ;Loop 15 times            ;Done,   

   MOV   AH,09H      ;  display   
   LEA   DX,CONAME   ;  CONAME   
   INT   21H   
   MOV   AX,4C00H   ;End processing   
   INT   21HA
A10MAIN   ENDP
            END     BEGIN

josefalarka

Thanks for you help. I got it.  This code is a 16 bit dos programming.  I use A86 as my assembler, now I started to learn. Thanks.

dedndave

QuoteI use A86 as my assembler, now I started to learn
ouch !
in the upper right-hand corner of the forum are several links
download the masm32 package - it's free   :U