flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 16 Aug 2009, 09:56
1. You might want to search for "arbitrary precision computation". Basically concatenate multiple memory locations together to store one large number.
2. Once you get your program working then you can consider optimising it if, and only if, it does not perform to the required specification or, perhaps also if you just want some optimising experience for the sake of it. 3. Base conversion is really just a matter of repeatedly dividing by your base and saving the remainders, for display use the reverse order, or for storage directly in little endian format. |
|||
![]() |
|
pal 16 Aug 2009, 13:25
Yeah, for number 1 that was what I was going to do.
The only problem is that I don't know how many bytes (or dwords as I have been working with before) something will take up. I was thinking for example something like this: First parameter is a pointer to a memory address. The second parameter is the number of bytes in the memory address that contain relevant data. Loop through this data doing the different operations. Output to a third parameter which contains a pointer to a memory location for output. The only problem is, how do I know, with some functions, how many bytes I will need? E.g. Should I just take a log10 of the data (e.g. for 54321 * 12345 do a log(54321 * 12345)) and then round up, so in that example it would be 8.8 = 9 digits, and allocate an appropriate amount of memory? |
|||
![]() |
|
vid 16 Aug 2009, 13:46
This article may be of some help to you: http://x86asm.net/articles/working-with-big-numbers-using-x86-instructions/index.html
Quote: The only problem is, how do I know, with some functions, how many bytes I will need? You can just estimate needed size in the beginning, and grow block of it needs to be larger (and optionally reallocate it to exact size when resulting size is known, if you are really concerned about memory and not so much about speed). But it is also common to just pick "large enough" fixed size and use that. |
|||
![]() |
|
Picnic 30 Sep 2009, 15:38
pal wrote:
This article also may be of some help, it shows a simple base conversion algorithm for arbitary size positive integers in any base 2-36. Check the comments for correct output length computation. I run some thousand digits conversion tests using googol+ to verify results. http://www.codeproject.com/KB/recipes/BaseConverter.aspx |
|||
![]() |
|
pal 01 Oct 2009, 16:51
Picnic: Thanks, thats a nice find (the link). And also I didn't know about that Googol+ program, it looks very good. How does it compare to GP/PARI (if you have ever used it)?
|
|||
![]() |
|
Picnic 03 Oct 2009, 13:57
You're welcome pal. No i have neved used PARI/GP, searching about big numbers base conversion utility some time ago i discovered Googol+. Unfortunately it's not free.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.