3 Replies - 2500 Views - Last Post: 20 March 2012 - 07:08 PM

#1 mikex6989  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 101
  • Joined: 18-February 11

Converting Uppercase to Lowercase, Lowercase to Uppercase

Posted 20 March 2012 - 11:26 AM

I need to convert all lower case to uppercase and then uppercase to lowercase. I only know how to convert the first character in myMessage to lowercase...how would I apply this to the entire string?


TITLE MASM Template						(main.asm)

INCLUDE Irvine32.inc
.data

myMessage BYTE 'Fuzzy WuZZY was A bear!',13,10,0  


.code
main PROC
	call Clrscr

	mov	 edx,OFFSET myMessage
	call WriteString
	mov cx, 1
	start:
	or [myMessage], 32


	loop start
	call WriteString

	exit
main ENDP

END main



This post has been edited by mikex6989: 20 March 2012 - 11:26 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Converting Uppercase to Lowercase, Lowercase to Uppercase

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 727
  • View blog
  • Posts: 1,990
  • Joined: 28-March 11

Re: Converting Uppercase to Lowercase, Lowercase to Uppercase

Posted 20 March 2012 - 02:26 PM

main PROC
	call Clrscr

	mov     edx, OFFSET myMessage
	call    WriteString
    
    push    edx
    call    Str_length
    xchg    eax, ecx
    sub     ecx, 4
    
FuzzyWuzzy:
    cmp     byte ptr[edx + ecx], 32
    je      @F
	xor     byte ptr[edx + ecx], 32

@@:
    dec     ecx
    jns     FuzzyWuzzy

	call    WriteString

	exit
main ENDP

Was This Post Helpful? 0
  • +
  • -

#3 mikex6989  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 101
  • Joined: 18-February 11

Re: Converting Uppercase to Lowercase, Lowercase to Uppercase

Posted 20 March 2012 - 06:51 PM

Wow! Thanks a lot..Could you help explain what each line is doing? Thanks again.
Was This Post Helpful? 0
  • +
  • -

#4 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 727
  • View blog
  • Posts: 1,990
  • Joined: 28-March 11

Re: Converting Uppercase to Lowercase, Lowercase to Uppercase

Posted 20 March 2012 - 07:08 PM

main PROC
	call Clrscr

	mov     edx, OFFSET myMessage
	call    WriteString
    
    push    edx                         ; edx still contains the address of the string
    call    Str_length                  ; get length of string function from irvine32.lib
    xchg    eax, ecx                    ; move string length into ecx
    sub     ecx, 4                      ; decrease length counter by 4(Length - char 13 - char 10 - NULL - 1 something)
    
    ; we will start at end of string
FuzzyWuzzy:
    cmp     byte ptr[edx + ecx], 32     ; compare byte at current pointer to 32 (Space)
    je      @F                          ; we have a space skip xor
	xor     byte ptr[edx + ecx], 32     ; xor byte at current pointer

@@:
    dec     ecx                         ; decrease our pointer offset
    jns     FuzzyWuzzy                  ; is ecx signed? No, GoTo FuzzyWuzzy
                                        ; else we are done

	call    WriteString

	exit
main ENDP

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1