Quantcast

Jump to content

» «
Photo

Upper to Lower case conversion

4 replies to this topic
Lev_Landau
  • Lev_Landau

    Player Hater

  • Members
  • Joined: 11 Aug 2013

#1

Posted 16 December 2013 - 02:36 AM Edited by Lev_Landau, 16 December 2013 - 02:42 AM.

My variable stores a string:

0@v = "UpperToLower"

I need a function, that does the upper case to lower case conversion trick, something like:

0AB1: call_scm_func @CONVERT 4 0@ 1@ 2@ 3@ return 0@v

Now variable 0@v stores this string:

0@v == "uppertolower"

Any help is really appreciated, Thank You


fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • None

#2

Posted 16 December 2013 - 06:14 AM

:LowerString
{
 Description: 
    Returns string with all alphabetic characters converted to lowercase.
 Type: SET  
 
 
 Parameters:
   Passed:
     0@, 1@, 2@, 3@ (0@v) - long string to lower
     4@ - type of variable to return (2 - short var, 4 - long var) 
 
 Example:
  0AB1: call_scm_func @LowerString 5 string 1@ 2@ 0 0 return_type 2 1@ 2@       
}
0A9F: 5@ = current_thread_pointer
5@ += 60    // 0@ adress  


:LowerStringLoop
0A8D: 6@ = read_memory 5@ size 1 virtual_protect 0
   
if
6@ <> 0x00
else_jump @LowerStringReturn

    if and
    6@ >= 65
    6@ <= 90
    then
    6@ += 32
    0A8C: write_memory 5@ size 1 value 6@ virtual_protect 0
    end
    
5@ += 1       
jump @LowerStringLoop

:LowerStringReturn

    if
    4@ == 4
    then
    0AB2: ret 4 0@ 1@ 2@ 3@
    else
    0AB2: ret 2 0@ 1@ 
    end

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci Racing
  • Joined: 19 Aug 2006
  • Unknown

#3

Posted 16 December 2013 - 11:58 AM Edited by Wesser, 16 December 2013 - 12:18 PM.

Simple as hell (untested):
  • CLEO3:
    const
        //_convertStringToUpcase = 0x00718710
        _convertStringToLowcase = 0x00718740
    end
    0A9F: 4@ = current_thread_pointer
    4@ += 0x3C // CScriptThread.m_aiLocalVars
    //0A90: 5@ = 0 * 0x04 // LVAR_ID * sizeof(CScriptThread.m_aiLocalVars[0])
    //005A: 4@ += 5@
    //0AA5: call _convertStringToUpcase num_params 1 pop 1 pszString 4@
    0AA5: call _convertStringToLowcase num_params 1 pop 1 pszString 4@
  • CLEO4 (correction by _DK):
    const
        //_convertStringToUpcase = 0x00718710
        _convertStringToLowcase = 0x00718740
    end
    //0AA5: call _convertStringToUpcase num_params 1 pop 1 pszString 0@v
    0AA5: call _convertStringToLowcase num_params 1 pop 1 pszString 0@v
SCM functions look ugly here.
  • _DK likes this

_DK
  • _DK

    Homie

  • Feroci Racing
  • Joined: 12 Apr 2009
  • Brazil

#4

Posted 16 December 2013 - 12:03 PM Edited by _DK, 16 December 2013 - 12:03 PM.

Or even using directly 0@v as paramter for 0AA5 with CLEO4 :)
0AA5: call _convertStringToLowcase num_params 1 pop 1 pszString 0@v

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci Racing
  • Joined: 19 Aug 2006
  • Unknown

#5

Posted 16 December 2013 - 12:31 PM

Heh, I'm not quite familiar with CLEO4. :p




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users