News:

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

convert to ascii

Started by ragdog, September 07, 2008, 10:03:31 PM

Previous topic - Next topic

ragdog

hi

i have a little problem for convert hex to ascii

85007200620074006500

this routine stops by the first 00 bytes and print me the first signs


HexDecode proc uses esi edi ebx pHexStr:dword,pOutBuffer:dword
mov esi,pHexStr
mov edi,pOutBuffer
jmp @1
@@:
and ebx,0Fh
add eax,ebx
mov [edi],al
inc edi
@1:
movzx edx,byte ptr[esi]
cmp edx,40h
sbb ebx,ebx
sub edx,37h
and ebx,7
inc esi
add ebx,edx
js @F
mov eax,ebx
shl eax,4
mov [edi],al
movzx edx,byte ptr[esi]
cmp edx,40h
sbb ebx,ebx
sub edx,37h
and ebx,7
inc esi
add ebx,edx
jns @B
@@:
ret
HexDecode endp




can your help me please

greets

drizz

You can't see the forest for the trees? The proc works just fine.




ps. WideCharToMultiByte
The truth cannot be learned ... it can only be recognized.

ragdog

lol :bg

No Drizz this proc cannot convert if 0 bytes in a hex string

example:
85007200620074006500 convert only the fist byte 85

857262... without 0 bytes works perfect!

i have my problem solved with this


         push offset sztext
         call remZero
         
         push offset hOut
         push offset sztext
         call HexDecode

remZero proc txt:DWORD

    mov ecx, txt
    mov edx, txt

  @@:
    mov al, [ecx]
    add ecx, 1
    cmp al, '0'     ; is it a space
    je @B
    mov [edx], al
    add edx, 1
    test al, al     ; is AL zero
    jnz @B

    ret

remZero endp

HexDecode proc
..
..
.


greets
ragdog