 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Sean1337 Master Cheater
Reputation: 0
Joined: 04 May 2007 Posts: 478
|
Posted: Mon Aug 06, 2007 12:22 am Post subject: Dword To Hex Conversion in MASM |
|
|
Hey,
I've been trying to convert a dword to hexa for the past few hours and haven't really succeeded.
Basically what I'm doing is this.
I get a value (type dword) from a pointer.
My objective is to convert this dword to hexadecimal. E.g. if value is 16, I want to convert it to 10 in hex.
I'm not exactly sure how one might do this in MASM32 since I only started probably a few months back, but I do know, in visual basic you can use the modulus and integer division operators to do it. I.e.
16 div 16 = 1
16 mod 16 = 0 (remainder)
1 div 16 = 0
1 mod 16 = 1 (remainder)
Reading remainder's backwards, decimal 16 = hexadecimal 10.
Does anyone know how to do this in MASM32? I'd greatly appreciate it.
Thanks,
-Sean
|
|
| Back to top |
|
 |
opcode0x90 Cheater
Reputation: 0
Joined: 05 Aug 2006 Posts: 27
|
Posted: Mon Aug 06, 2007 1:31 am Post subject: |
|
|
| Code: |
.data
lpHexString db "0123456789ABCDEF"
.code
Dec2Hex proc dwValue:DWORD, lpBuffer:DWORD
mov edi, lpBuffer
mov eax, dwValue
mov ecx, 8
.repeat
mov esi, eax
and esi, 0F0000000h
shr esi, 28
movzx edx, byte ptr [lpHexString+esi]
mov byte ptr [edi], dl
shl eax, 4
inc edi
.untilcxz
ret
Dec2Hex endp
|
Example:
| Code: |
invoke Dec2Hex, 1337C0DEh, addr lpBuffer
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|