News:

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

string to hex

Started by gamer, January 20, 2011, 03:23:08 AM

Previous topic - Next topic

gamer

Hi,

I am new to masm32 and want to start with conversion stuff.  I tried to google about this before asking but the watever code i found there i am facing couple of issues while compiling.

.386
.model flat,stdcall
option casemap:none

include kernel32.inc
include windows.inc
include user32.inc

includelib user32.lib
includelib kernel32.lib

.data
HexWord db "Encodeme",0

.data?
hOut db 260 dup (?)

.code
start:
push offset hOut
push offset HexWord
call HexEncode
invoke MessageBox,0,addr hOut ,0,MB_OK
invoke ExitProcess,0

HexEncode proc uses edi esi ebx pBuff:dword,dwLen:dword,pOutBuff:dword
;---------------------------------------
  mov    ebx, dwLen
  mov    edi, pOutBuff
  test    ebx, ebx
  mov    esi, pBuff
  jz      @F
  .repeat
    movzx  eax, byte ptr [esi]
    mov    ecx, eax
    add    edi, 2
    shr    ecx, 4
    and    eax, 1111b
    and    ecx, 1111b
    cmp    eax, 10
    sbb    edx, edx
    adc    eax, 0
    lea    eax, [eax+edx*8+'7']
    cmp    ecx, 10
    sbb    edx, edx
    adc    ecx, 0
    shl    eax, 8
    lea    ecx, [ecx+edx*8+'7']
    or      eax, ecx
    inc    esi
    mov    [edi-2], ax
    dec    ebx
  .until ZERO?
@@: mov    eax, edi
  mov    byte ptr [edi], 0
  sub    eax, pOutBuff
  ret
;---------------------------------------
HexEncode endp
end start


This is the source which i got via searching on google. but now the problem is this i am having problem while compiling it.  There is one or two error which I am not able to figure out.  anyone can help me out in this case??

dedndave

right off - i see that the routine has 3 parameters - and you only push 2
but that shouldn't cause it not to assemble
please tell us specifically what the errors are and what command line you are using to assemble
if the \masm32\bin folder is in the path, you should be able to use "build.bat"

if you have installed the masm32 package, assembly should be done on the same drive as the install
then, the include's and includelib's must have root-relative paths
.386
.model flat,stdcall
option casemap:none

include \masm32\include\kernel32.inc
include \masm32\include\windows.inc
include \masm32\include\user32.inc

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


you can replace all of the above with a single line
include \masm32\include\masm32rt.inc
you can look inside that file to see what it involves

EDIT - oh
and "Encodeme" is hardly a valid hex string   :P
at best, the routine will return a value of 14 decimal

i see that isn't what the routine does   :bg
if you push the length of the string, it will probably work
let me try it...

dedndave

i also added a PROTOtype and squared away the parms
see attached file...

gamer


dedndave

i wish all the problems were so simple   :P