Jump to content

Getting an asterix at the end of output in case conversion program

- - - - -

  • Please log in to reply
1 reply to this topic

#1
devjeetroy

devjeetroy

    Newbie

  • Members
  • Pip
  • 5 posts
Hello Guys,
I was writing some programs, using questions in a book by Kip Irvine, for practice. I'd already done conversion from lower case to upper case using AND. Now, I figured I'd do it the other way round, upper case to lower case. Here is my program:
.386

.model flat, stdcall

option casemap:none


CR EQU 13

LF EQU 10


include \masm32\include\windows.inc

include \masm32\include\kernel32.inc

include \masm32\include\masm32.inc


includelib \masm32\lib\kernel32.lib

includelib \masm32\lib\masm32.lib


.data

prompt BYTE "Please Enter A String:", CR,LF, 0

prompt1 BYTE "OutPut:", 0


.data?

inp BYTE 120 DUP(?)



.code

        main PROC

        INVOKE StdOut, ADDR prompt

        INVOKE StdIn, ADDR inp, 120

        pushad

        INVOKE StripLF, ADDR inp

        popad

        CALL rev

        INVOKE StdOut, ADDR prompt1

        INVOKE StdOut, ADDR inp

        INVOKE ExitProcess,0

        main ENDP



        rev PROC

        mov ecx, SIZEOF inp

        mov esi, OFFSET inp

        L1:

                or BYTE PTR [esi], 00100000b

                inc esi

                loop L1

        RET

        rev ENDP        



        END main       
Sorry, I didn't write any comments. I basically used a procedure for the case conversion and masm32 library for input and output.
Here is the sample IO:

Quote

C:\masm32\CODE>toLowerCase.exe
Please Enter A String:
HELLO
OutPut:hello *

C:\masm32\CODE>toLowerCase.exe
Please Enter A String:
HELLO WORLD
OutPut:hello world *

I am fixed about the '*' character at the end of the string and cant seem to get it out. I also used the StripLF procedure to remove Carriage Return and Line Feed characters. The only time the '*' disappeared was when i changed the length of 'inp', corresponding to the exact length of the string entered by the user. Please help me out!
Thanks!
Devjeet

#2
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
Why not use something like this?:
Take the address of the string. 

loop1: 

If the byte at that address is equal to 0, go to loop1s. 

If the byte at that address is not greater than 64, go to lbl1. 

If the byte at that address is not less than or equal to (64 + 26), go to lbl1. 

Add 32 to the byte at that address. 

lbl1: 

Increment that address. 

Go to loop1. 

loop1s: 
I just don't get what the OR does, in your code.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users