
; ## Consts

    String.FORMAT_BIN = 2
    String.FORMAT_DEC = 10
    String.FORMAT_HEX = 16

String:

	; ## Convert EAX value to string in the specified format
	;  + EAX: Value to convert
	;  + EBX: Format        (2 = binary; 10 = decimal; 16 = hexadecimal)
	;  + ECX: String Size   (remember to add terminator char space)
	;  + ESI: String Buffer (must have <string size> size)

    .eax2str:
		xor  ecx, ecx
	    @@: xor  edx, edx
		div  ebx
		cmp  edx, 10		; 10 = A
		jnae .skpHx
		add  edx, 'A'-'9'-1	; Hex offset (A,B,C,D,E,F)
	.skpHx: add  edx, '0'		; ascii offset
		push edx		; store remainder
		inc  ecx		; string lenght counter
		test eax, eax
		jnz  @b
	    @@: pop  ebx		; reload remainder
		mov  byte[esi], bl
		inc  esi
		inc  eax
		cmp  eax, ecx
		jne  @b
		;mov  byte[esi+eax], '$' ; end string
		ret

	; ## Convert EAX value to string in the specified format with zero filled
	;  + EAX: Value to convert
	;  + EBX: Format        (2 = binary; 10 = decimal; 16 = hexadecimal)
	;  + ECX: String size   (remember to add terminator char space)
	;  + ESI: String buffer (must have <string size> size)

    .eax2str_zf:
		mov  byte[esi+ecx], '$' ; end string
	    @@: xor  edx, edx
		div  ebx
		cmp  edx, 10		; 10 = A
		jnae .skpHxf
		add  edx, 'A'-'9'-1	; Hex offset (A,B,C,D,E,F)
       .skpHxf: add  edx, '0'		; ascii offset
		dec  ecx		; string lenght [de]counter
		mov  byte[esi+ecx], dl
		jnz  @b
		ret