I would like to convert the following text:
"My data is Little Endian"
into hexadecimal ASCII codes, using MASM32 library function StdOut. Using the text buffer as an array of DWORD elements..
hi
try this
TextToHex PROTO :DWORD,:DWORD,:DWORD
b2hex PROTO :BYTE,:DWORD
.code
TextToHex proc uses edi esi Src: DWORD, Dst: DWORD, Len: DWORD
; =====================================
; Convert Src binary data to hex in Dst
; =====================================
mov esi, Src
mov edi, Dst
@@:
invoke b2hex, [esi], edi
inc edi
inc edi
mov byte ptr[edi], ' '
inc edi
inc esi
dec Len
jnz @B
mov byte ptr[edi-1], 0 ; Write NULL terminator
ret
TextToHex endp
b2hex proc source: BYTE, lpBuffer: DWORD
; ==========================
; Convert source byte to hex
; ==========================
mov edx, lpBuffer
xor eax, eax
xor ecx, ecx
mov cl, source
mov al, cl
and al, 00001111b
cmp al, 10
sbb al, 69h
das
mov [edx+1], al
mov al, cl
shr al, 4
cmp al, 10
sbb al, 69h
das
mov [edx], al
ret
b2hex endp