Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Samples

dw2hex - dword to hexadecimal

A community discussion post from the original code:zIRON forum.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

dw2hex - dword to hexadecimal

Another sample function for dword to hexadecimal conversion, it is very simple and probably could be optimized if you are not bothered to preserve ecx - edi

//
// dw2hex - Code::zIron. 2012.
// buf len minimum length 12 bytes
//
function dw2hex(DWord val; char* buf) {
	uses ecx edi esi;
	
	edi = buf;
	ecx = val;
	esi = '0123456789ABCDEF';
			
	$repeat 8:
		eax = ecx;
		eax >> 28;

		al = [esi+eax];
		stosb

		ecx << 4;
	$end;
	
	char*[edi] = "h";
	
	return buf;
}