flat assembler
Message board for the users of flat assembler.
Index
> Windows > [HELP] - Converting string of integers to hexadecimal |
Author |
|
JohnFound 08 Feb 2011, 21:48
Well, there are two tasks - converting string to number and from number to string, but with different radix.
FreshLib have a library StrLib where exists both NumToStr and StrToNum procedures. You can download FreshLib with Fresh The file is: Fresh/FreshLib/data/StrLib.asm At least you can get some ideas from the source. |
|||
08 Feb 2011, 21:48 |
|
b1528932 08 Feb 2011, 23:40
data should be held in normal form.
Then get lowest 16^1/2 bits, map to 16 possible codepoints, write out codepoint, shift data pointer up, repeat untill pointer reach beyond data. The other way around is to get a codepoint, convert to real data, and add to buffer in the current pointer position*4. Increment ponter. Repeat untill pointer reach beyond string data. Converting decimal string is same. You take a character, convert it into a data, add into buffer. But here you have to multiply it before, because 10 cant be represented as a single 2^n and because of this you cant multiply-by-shift. |
|||
08 Feb 2011, 23:40 |
|
ctl3d32 09 Feb 2011, 00:28
Thanks for the quick reply! I will give it a try.
|
|||
09 Feb 2011, 00:28 |
|
Alphonso 09 Feb 2011, 10:05
Since this is the Windows section, if your only looking at 64bit hex numbers then a lazy way (32-bit code) might be
Code: ;---------------------------------------- section '.text' code readable executable cinvoke wsprintf,Buff,wsformat,dword[num],dword[num+4] invoke MessageBox,0,Buff,0,0 invoke ExitProcess,0 ;---------------------------------------- section '.data' data readable writeable wsformat db '%016I64X',0 align 4 num dq 4340934073110 Buff rb 20 whoops, thanks Rev. Last edited by Alphonso on 09 Feb 2011, 10:24; edited 3 times in total |
|||
09 Feb 2011, 10:05 |
|
revolution 09 Feb 2011, 10:09
Alphonso: use cinvoke for wsprintf.
|
|||
09 Feb 2011, 10:09 |
|
ctl3d32 09 Feb 2011, 22:19
Thanks bro!
|
|||
09 Feb 2011, 22:19 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.