Analog Devices adsp-2100 Manual page 450

Adsp-2100 family programmable single-chip microprocessors
Table of Contents

Advertisement

Return Values
AR = 16-bit quotient
MR0 = 16-bit remainder
AV flag set if divide would overflow
Altered Registers
AX0, AX1, AR, AF, AY0, AY1, MR, MY0
Computation Time: 30 cycles
}
.ENTRY
signed_div, unsigned_div;
signed_div:
MR0=AY0,AF=AX0+AY1;
MR1=AY1, AR=ABS AX0;
test_1:
IF NE JUMP test_2;
ASTAT=0x4;
RTS;
test_2:
IF NOT AV JUMP test_3;
AY0=AY1, AF=ABS AY1;
IF NOT AV JUMP recover_sign;
ASTAT=0x4;
RTS;
test_3:
AF=PASS AF;
IF NE JUMP test_4;
AY0=0x8000;
ASTAT=0x0;
JUMP recover_sign;
test_4:
AF=ABS MR1;
AR=ABS AX0;
AF=AF-AR;
IF LT JUMP do_divs;
ASTAT=0x4;
RTS;
Listing B.1 Division Error Routine
Division Exceptions
{Take divisor's absolute value}
{See if divisor, dividend have
same magnitude}
{If divisor non-zero, do test 2}
{Divide by zero, so overflow}
{Return to calling program}
{If divisor 0x8000, then the}
{quotient is simply -AY1}
{0x8000 divided by 0x8000,}
{so overflow}
{Check for division overflow}
{Not equal, jump test 4}
{Quotient equals -1}
{Clear AS bit of ASTAT}
{Compute remainder}
{Get absolute of dividend}
{Restore AS bit of ASTAT}
{Check for division overflow}
{If Divisor>Dividend do divide}
{Division overflow}
(continues on next page)
B
B – 7

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents