flat assembler
Message board for the users of flat assembler.
Index
> Windows > please help (fixed point math) |
Author |
|
LocoDelAssembly 02 Oct 2007, 17:03
Code: sar edx,16 shl edx,16 Same as just Code: and edx, $FFFF0000 And IDIV faults when (EDX != -1) OR (EDX != 0) after division. The division algo is not properly scaling the number. Here my version Code: macro fixdiv Des,Src,Tar { mov eax,Src mov edx, 1 shl 16 imul edx idiv Tar mov Des,eax } Note that this topic was discussed and someone even wrote an article on this forum, search for it. In case you don't want to use IMUL this is another way Code: macro fixdiv Des,Src,Tar { mov eax,Src cdq shld edx, eax, 16 shl eax, 16 idiv Tar mov Des,eax } [edit]Or Code: macro fixdiv Des,Src,Tar { mov eax,Src mov edx, eax shl eax, 16 sar edx, 16 idiv Tar mov Des,eax } |
|||
02 Oct 2007, 17:03 |
|
rain_storm 02 Oct 2007, 19:33
I will use your version since it works and its only 5 instructions =D
Thank you Loco' for the quick reply |
|||
02 Oct 2007, 19:33 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.