News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

please help

Started by royale, January 25, 2009, 04:38:11 AM

Previous topic - Next topic

royale

how to convert a string of letters like abc to 123? anyone knows?

dsouza123

For this very particular conversion the following code will work,
but more information is needed.

A translation table to show how to convert between the letters and numbers.
Is it in chunks of letters or individual characters, is it a hex string to decimal string ?


    .686
    .model flat, stdcall
    option casemap :none
    include \masm32\include\windows.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\user32.inc

    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\user32.lib

.data
  szInfo   db "abc",0
  szBTitle db "Before",0
  szATitle db "After ",0

.code
start:
   invoke MessageBox,NULL,ADDR szInfo,ADDR szBTitle,MB_OK

   mov eax, dword ptr szInfo
   sub eax, 303030h
   mov dword ptr szInfo, eax

   invoke MessageBox,NULL,ADDR szInfo,ADDR szATitle,MB_OK

   invoke  ExitProcess, 0
end start

Vortex

royale,

Have a look at the Masm32 library reference. It provides a lot of convertion functions. Study the functions to create your own convertion routines.

MichaelW

royale,

I'm assuming that this is the same question as in your encoding post. Assuming that the string will contain only the lower-case letters a-z, then the encoding can be done by subtracting 96 from the ASCII character code for each character in the string. For example:
The ASCII character code for 'a' is 97, and 97-96 = 1
The ASCII character code for 'b' is 98, and 98-96 = 2
...
eschew obfuscation