Truncated match.
PICList
Thread
'16BIT DIVISION'
1999\10\27@172953
by
anbarsystem
Hallo all!
I am looking for a routine in ASM that make a division of a 16bit binary
number for 5 .
For example.
015Eh / 05 = 046h
So my 16bit binary number will never be larger than 03DEH, with this I will
need only 1 byte for the result.
Any idea?
Any help would be appreciated
Thanks in advanced
Luis F.
1999\10\27@191508
by
Keith Causey
part 0 72 bytes
Attachment converted: wonderland:sx_arith(1).pdf (PDF /CARO) (0000E8DC)
1999\10\27@195420
by
Robert A. LaBudde

<xflowed>At 07:19 PM 10/27/99 0200, Luis wrote:
>Hallo all!
>I am looking for a routine in ASM that make a division of a 16bit binary
>number for 5 .
>For example.
>015Eh / 05 = 046h
>
>So my 16bit binary number will never be larger than 03DEH, with this I will
>need only 1 byte for the result.
If you only need to divide by five, and you don't want to write a standard
division routine, you can do the following:
1. Form y = x/4. (You shift your dividend by 2 bits to the right.)
2. Add y to sum.
2. Form z = y/4. Subtract from sum.
3. Form w = z/4. Add to sum.
4. Form v = w/4. Subtract from sum. (This is sufficient for 3DE or less.)
5. Form u = v/4. Add to sum.
6. Form t = u/4. Add to sum.
7. Form s = u/4. Add to sum. (This is sufficient for FFFF dividend.)
For your 3DE or less, you need to add four terms, each of which is shifted
2 bits from the previous value. You can create a macro for this, or a
subroutine.
================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS email: spam_OUTralTakeThisOuTlcfltd.com
Least Cost Formulations, Ltd. URL: http://lcfltd.com/
824 Timberlake Drive Tel: 7574670954
Virginia Beach, VA 234643239 Fax: 7574672947
"Vere scire est per causae scire"
================================================================
</xflowed>
1999\10\28@035701
by
Nikolai Golovchenko
Hi Robert!
I've got interested by this way of division. How do you decompose 1/5 into
(1/41/16+1/641/256...)? It may be useful in digital filter design with
fixed weights :)
Regards,
Nikolai
{Original Message removed}
1999\10\28@084313
by
Nikolai Golovchenko

Hey, I guessed!
If you have to divide or multiply a number by a constant there is a
possibility to optimize this routine for the given constant. Multiplication
and division are treated the same, because the constant can be fractional
and regarded as multiplier in both cases.
Example:
Assume constant multiplier c=3.578 and variable v is 16 bit long.
Step1. Convert c to binary fractional form:
3.578(dec) = 11.1001 0011 1111 0111 1100 ...(bin)
Step2. Replace series of ones with difference
All series of two and more one's can be replaced by differences. For
example, 1111 = 10000  1. The difference requires only one substraction
instead of four additions.
If there are no such series than optimization not possible.
3.578(dec) = 100.0001 0100 0000 0000 0000..(bin)
 0.1000 0000 0000 0000 0100..(bin) =
= 4  1/2 + 1/16 + 1/64  ...(dec).
Step3. Limit fractional part of positive and negative constant multiplier to
161 bits. 16th bit can be used to round multiplication result.
3.578 = 4  1/2 + 1/16 + 1/64
Step4.Now shift v and add and sub...... ;)
Am I right?
Bye.
Nikolai
1999\10\28@104458
by
Robert A. LaBudde
<xflowed>At 10:24 AM 10/28/99 +0300, you wrote:
>Hi Robert!
>
>I've got interested by this way of division. How do you decompose 1/5 into
>(1/41/16+1/641/256...)? It may be useful in digital filter design with
>fixed weights :)
>
>Regards,
>Nikolai
X / 5 = X/(4+1) = (X/4) /(1+1/4)= (X/4) * (1  1/4 + 1/16  1/64 + 1/256 ...)
= X/4  X/16 + X/64  X/256 + X/1024  X/4096 ...
================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS email: .....ralKILLspam@spam@lcfltd.com
Least Cost Formulations, Ltd. URL: http://lcfltd.com/
824 Timberlake Drive Tel: 7574670954
Virginia Beach, VA 234643239 Fax: 7574672947
"Vere scire est per causae scire"
================================================================
</xflowed>
1999\10\28@152146
by
AndrŽ Labelle
"Robert A. LaBudde" wrote:
{Quote hidden}>
> At 10:24 AM 10/28/99 +0300, you wrote:
> >Hi Robert!
> >
> >I've got interested by this way of division. How do you decompose 1/5 into
> >(1/41/16+1/641/256...)? It may be useful in digital filter design with
> >fixed weights :)
> >
> >Regards,
> >Nikolai
>
> X / 5 = X/(4+1) = (X/4) /(1+1/4)= (X/4) * (1  1/4 + 1/16  1/64 + 1/256 ...)
> = X/4  X/16 + X/64  X/256 + X/1024  X/4096 ...
>
> ================================================================
> Robert A. LaBudde, PhD, PAS, Dpl. ACAFS email:
ralKILLspamlcfltd.com
> Least Cost Formulations, Ltd. URL:
http://lcfltd.com/
> 824 Timberlake Drive Tel: 7574670954
> Virginia Beach, VA 234643239 Fax: 7574672947
>
> "Vere scire est per causae scire"
> ================================================================
Hello,
An alternative method would be:
result = 0;
while(X>=5)
{
X = X  5;
result = result + 1;
}
Andre
1999\10\28@171521
by
Jose Souto
part 0 88 bytes
BRegards,
JSouto
Attachment converted: wonderland:udiv16x8.zip (pZIP/pZIP) (0000E976)
'16BIT DIVISION'
1999\12\13@142405
by
jamesnewton

In my text companding project, I'll be dividing by 96 allot so I wrote this
little thing:
INPUT "enter number to divide by: ", in
INPUT "bit precision: ", bits
accum = 1 / in
i = .5
j = 1
WHILE j < bits
ni = i / 2
PRINT "shift dividend right. Shift#"; j
IF accum < 0 THEN 'neg
IF ABS(accum + ni) > ABS(accum + i) THEN
PRINT "add dividend to accumulator after shift#"; j; "(dividend
/"; 1 / i
accum = accum + i
END IF
ELSE
IF ABS(accum  ni) > ABS(accum  i) THEN
PRINT "subtract dividend from accumulator after shift#"; j;
"(dividend /"; 1 / i
accum = accum  i
END IF
END IF
j = j + 1
i = ni
WEND
PRINT "Final error:"; accum; "would require 1/"; 1 / accum; "th of dividend
to be added to accumulator"
I thought it might be of use to someone.
James Newton .....jamesnewtonKILLspam.....geocities.com phone:16196520593
http://techref.homepage.com NOW OPEN (R/O) TO NONMEMBERS!
Members can add private/public comments/pages ($0 TANSTAAFL web hosting)
PIC/PICList FAQ: http://www.piclist.com
{Original Message removed}
More... (looser matching)
 Last day of these posts
 In 1999
, 2000 only
 Today
 New search...