flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
gunblade
That would depend on the operating system you are on.
First, to convert the value to a string equivalent of it, use this code: Code: IntToStr: ; eax = number, ebx = base, edi = buffer push ecx edx xor ecx,ecx .new: xor edx,edx div ebx push edx inc ecx test eax,eax jnz .new .loop: pop eax add al,30h cmp al,'9' jng .ok add al,7 .ok: stosb loop .loop mov al,0 stosb pop edx ecx ret This isnt mine, I found it on this board somewhere, sorry to whoever wrote it for not putting your name here, I just never noted it down. But great code. You would then output it using the OS-specific API. For linux, you would use something along the lines of: Code: mov eax, 4 mov ebx, 1 mov ecx, addressofstring mov edx, lengthofstring int 0x80 Oh, and a tip, you can find the length of the string made by the code at the top by doing: Code: sub edi, addressofstring after calling it. Good luck, gunblade |
|||
![]() |
|
Patrick_
Thanks for the response. However, I have a few questions:
First, since it's my third day of learning/programming in assembly, could you please comment the lines? I can understand some of it, but I'm not quite sure what's totally going on. Also, the comment says that ebx is the base... what do you mean by base? Like base-10, base-6 (hex), etc? Or something else? Thanks for that tip, too. I was wondering how I'd do that. ![]() |
|||
![]() |
|
rugxulo
Check here for a fast bin2dec routine (Terje Mathisen, GPL): http://board.flatassembler.net/topic.php?t=3924
|
|||
![]() |
|
Madis731
Yeah, it should be the fastest (60 clocks) against the traditional divide_by_10_and_take_the_reminder approach
![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.