News:

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

how to call the bin2hex proc

Started by Eric4ever, May 26, 2006, 05:55:56 AM

Previous topic - Next topic

Eric4ever

i'm learning and trying to do the bin/hex convertion, but always failed. i do it like this: input a binary number into a edittext, the call the masm bin2hex proc(bin2hex.asm in the masm32\m32lib directory, i just only use the bin2hex proc as a proc of my asm file), at last output it into the hex edittext.

but i'm failed. i don't know why. (maybe the 'EXTERNDEF hex_table :DWORD' errors, maybe others compile well but the result is wrong).
how can i call the bin2hex proc rightly and get the right result.

thanks in advance.


MichaelW

I think the bin2hex procedure is actually intended for creating a hex dump of binary data.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
        bindata db 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
        hstr    db 60 dup(0)
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    invoke bin2hex,ADDR bindata,SIZEOF bindata,ADDR hstr
    print ustr$(eax),13,10
    print ADDR hstr,13,10
    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


50
00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F
Press any key to exit...

eschew obfuscation

Mark Jones

Quote from: Eric4ever on May 26, 2006, 05:55:56 AM
input a binary number into a edittext, the call the masm bin2hex proc...

Hi Eric, if you are typing in a value like "1000101" into an editbox to represent the decimal value 69, realize that "1000101" is read as ASCII string data bytes and is equivalent to:


.data
    MyInput  DB  31h, 30h, 30h, 30h, 31h, 30h, 31h


Let us know what you find. :U
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08