flat assembler
Message board for the users of flat assembler.
Index
> Main > MUL & DIV |
What is the most horrible bug ever ? | ||||||||||||||
|
||||||||||||||
Total Votes : 11 |
Author |
|
revolution 05 May 2008, 07:34
Multiplies are easy, just use the basic "schoolboy" cross multiply and add. For small numbers (<10000bits) this is the best for both speed and size with modern CPUs.
Divides can be done with shift/compare/subtract on a bit-by-bit basis but a faster (and slightly more complex) method is Barretts method for numbers larger than ~256bits. Google it. If you have a fixed divisor then you can always use the standard reciprocal multiply method. Depends on your applications needs. |
|||
05 May 2008, 07:34 |
|
vid 05 May 2008, 09:31
I think those algos are present in AMD optimization manual.
|
|||
05 May 2008, 09:31 |
|
rugxulo 05 May 2008, 16:58
|
|||
05 May 2008, 16:58 |
|
DOS386 07 May 2008, 08:52
> I think those algos are present in AMD optimization manual.
For 8086 also ? > http://www.geocities.com/snoopimeanie/32math64.txt Thanks ... but that's the standard 32->64 extension that can be found at various other places also And unusable for 8086 ... Now I found a MUL algo at least (test ASAP) ... Any ideas about division ? - var / var - var / const ( frac(lb(const))<>0 !!! ) |
|||
07 May 2008, 08:52 |
|
revolution 07 May 2008, 10:36
DOS386 wrote: For 8086 also ? Besides, 16bit code is wasting the CPU unless you have a genuine 808x or 8028x, but somehow I doubt that there are many systems around still in service and using one of those. |
|||
07 May 2008, 10:36 |
|
edfed 07 May 2008, 10:56
Quote:
totally true one more time. 808x & 8028x are completelly OBSOLETE. for multiply, i have a simple idea, based on shifting and adding. 32 iterations for 32 bits, 64 iterations for 64 bits for divide....sub and shift. 64 iterations for 64 bits. |
|||
07 May 2008, 10:56 |
|
rugxulo 24 May 2008, 22:23
http://www.dunfield.com/downloads.htm
Quote:
And since this is done under Micro-C, it's 8086 compatible (and you can easily output to .ASM to see what it's doing). |
|||
24 May 2008, 22:23 |
|
DOS386 01 Jun 2008, 22:42
Quote: So just remove all the 'e' from the register names and change all the offsets into 2 instead of 4. I don't see the problem. It is the method you need right? NO: 1. Removing "E" is no big deal really 2. No SHLD & SHRD, no easy shift by > 1 3. This way I would get 32 bits only (maybe I could "chain" the trick but very dirty way then) Quote: Surely you don't want someone to write all your code for you. Quote: {text_size=0.00000000001}Besides, 16bit code is wasting the CPU unless you have a genuine 808x or 8028x, but somehow I doubt that there are many systems around still in service and using one of those. COOL. edfed wrote: > totally true one more time. > 808x & 8028x are completelly OBSOLETE. Hey, then you must "upgrade" your famous Windaube 98 ASAP Quote: BIGNUM.ZIP (4K) Very large math ops (64+bits)with C source. That's what I needed ... but it's in C ... if someone has similar in 8086 assembly, please post And YES, 8086 assembly (avoiding AAM & Co) still is the preferred way to write down algorithms, ways better than Cobol, C++, Javas**t, ... |
|||
01 Jun 2008, 22:42 |
|
edfed 01 Jun 2008, 23:06
Quote: Hey, then you must "upgrade" your famous Windaube 98 ASAP i don't see what i can use instead of this daube. windaube XP? windaube 2000? windaube Vistahhhhh? windaube NT4? Linuxme? debian? ubuntu? Freebsd? no way, the only reason to change of OS is to have my own ready to use. Code: mov ax,n1 mov bx,n2 mov cx,1 mov dx,0 next: test ax,cx je @f add dx,bx @@: shl bx,1 shl cx,1 jne .next |
|||
01 Jun 2008, 23:06 |
|
DOS386 02 Jun 2008, 23:30
> windaube Vistahhhhh?
YES. Or Server 2008. Thanks for the Tomasz-style code |
|||
02 Jun 2008, 23:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.