.686
.model flat,stdcall
option casemap:none
includelib bin/kernel32.lib
;include io32.inc
ExitProcess proto,:DWORD
exit MACRO dwexitcode
invoke ExitProcess,dwexitcode
ENDM
GetStdHandle proto,:DWORD
WriteConsoleA proto,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WriteConsole equ <WriteConsoleA>
STD_OUTPUT_HANDLE = -11
.data
var byte '123456ABCDEFabcdef'
dhb_buf byte 3 dup(0)
dhd_buf byte 8 dup(0)
_outsize dword ?
_outhandle dword ?
_char byte ?
.code
start:
mov eax,offset var
mov ecx,lengthof var
call dispmem
exit 0
dispmem proc
mov ebx,eax
jmp k
outlp:
mov al,13
call dispcs
mov al,10
call dispcs
dec ecx
k: mov eax,ebx
call disphds
mov eax,3ah
call dispcs
xor edx,edx
inlp: mov al,[ebx]
call disphbs
inc ebx
inc edx
cmp edx,16
jz outlp
loop inlp
ret
dispmem endp
disphbs proc
pushad
mov ecx,2
xor edx,edx
lp: rol al,4
mov bl,al
and bl,0fh
add bl,30h
cmp bl,39h
jbe s
add bl,7
s: mov dhb_buf[edx],bl
inc edx
loop lp
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov _outhandle,eax
invoke WriteConsole,_outhandle,addr dhb_buf,3,addr _outsize,0
popad
ret
disphbs endp
disphds proc
pushad
mov ecx,8
xor edx,edx
lp: rol eax,4
mov bl,al
and bl,0fh
add bl,30h
cmp bl,39h
jbe s
add bl,7
s: mov dhd_buf[edx],bl
inc edx
loop lp
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov _outhandle,eax
invoke WriteConsole,_outhandle,addr dhd_buf,8,addr _outsize,0
popad
ret
disphds endp
dispcs proc
pushad
mov _char,al
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov _outhandle,eax
invoke WriteConsole,_outhandle,addr _char,1,addr _outsize,0
popad
ret
dispcs endp
end start