flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
vid 28 Feb 2009, 22:46
What for? For vast majority of purposes, DIV is fast enough.
|
|||
![]() |
|
Tomasz Grysztar 28 Feb 2009, 23:14
Try this tool: http://www.wasm.ru/baixado.php?mode=tool&id=203
If you need some more info, you may find this thread interesting: http://www.asmcommunity.net/board/index.php?topic=21308.0 (you can find me participating there) |
|||
![]() |
|
LocoDelAssembly 01 Mar 2009, 02:42
Note that The Svin's tool may not work for some numbers.
This code comes from a PM I've sent to a member of this forum to avoid pollution of a thread of that moment (I think): Code: include 'win32ax.inc' start: mov ecx, $FFFFFFFF ; -1 ; Only value in which it fails (uncomment "-1" and the program will end successfully) mov edi, 7 align 16 place: MagicNumber = 2454267026 ; 7 mov eax,ecx mov edx, MagicNumber inc eax mul edx SHR edx, 2 mov esi, edx mov eax, ecx xor edx, edx div edi cmp eax, esi jne fail sub ecx, 1 jnc place invoke MessageBox, 0, "all just fine!", "OK", 0 exit: invoke ExitProcess,0 fail: cinvoke wsprintf, buff, fmt, ecx, esi, eax invoke MessageBox, 0, buff, "ERROR!", 0 jmp exit fmt db "%u div 7 = %u but actually it is %u", 0 buff rb 256 .end start This doesn't happen with any number and I don't know if this is the only divisor that it is flawed or if there are more. |
|||
![]() |
|
Tomasz Grysztar 01 Mar 2009, 09:36
Yes, for a value near to 2^32 there may occur an overflow in some cases - see my analysis in the other thread. But for a significantly smaller values this should be a safe method.
|
|||
![]() |
|
manfred 01 Mar 2009, 09:47
Tomasz Grysztar wrote: Try this tool: http://www.wasm.ru/baixado.php?mode=tool&id=203 This is great, thanks! _________________ Sorry for my English... |
|||
![]() |
|
DOS386 01 Mar 2009, 12:05
Tomasz Grysztar wrote: Try this tool: http://www.wasm.ru/baixado.php?mode=tool&id=203 Interesting, OTOH not FASM ... Quote: If you need some more info, you may find this thread interesting: Oops, you are active in other forums than yours also ![]() I'll drop a deeper look into it and test maybe ![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.