The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on September 07, 2008, 10:03:31 PM

Title: convert to ascii
Post by: ragdog on September 07, 2008, 10:03:31 PM
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
Title: Re: convert to ascii
Post by: drizz on September 07, 2008, 10:59:56 PM
You can't see the forest for the trees? The proc works just fine.




ps. WideCharToMultiByte
Title: Re: convert to ascii
Post by: ragdog on September 08, 2008, 03:23:20 PM
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