B Division Exceptions
B – 8
do_divs: DIVS AY1, AR; DIVQ AR; {Compute sign of quotient}
DIVQ AR; DIVQ AR;
DIVQ AR; DIVQ AR;
DIVQ AR; DIVQ AR;
DIVQ AR; DIVQ AR;
DIVQ AR; DIVQ AR;
DIVQ AR; DIVQ AR;
DIVQ AR; DIVQ AR;
recover_sign: MY0=AX0,AR=PASS AY0; {Put quotient into AR}
IF NEG AR=-AY0; {Restore sign if necessary}
MR=MR-AR*MY0 (SS); {compute remainder dividend neg}
RTS; {Return to calling program}
unsigned_div: MR0=AY0, AF=PASS AY1; {Move dividend MSW to AF}
MR1=AY1, AR=PASS AX0; {Is MSB set?}
test_10: IF GT JUMP test_11; {No, so check overflow}
ASTAT=0x4; {Yes, so set overflow flag}
RTS; {Return to caller}
test_11: AR=AY1-AX0; {Is divisor<dividend?}
IF LT JUMP do_divq; {No, so go do unsigned divide}
ASTAT=0x4; {Set overflow flag}
RTS;
do_divq: ASTAT=0; {Clear AQ flag}
DIVQ AX0; DIVQ AX0; {Do the divide}
DIVQ AX0; DIVQ AX0;
DIVQ AX0; DIVQ AX0;
DIVQ AX0; DIVQ AX0;
DIVQ AX0; DIVQ AX0;
DIVQ AX0; DIVQ AX0;
DIVQ AX0; DIVQ AX0;
DIVQ AX0; DIVQ AX0;
uremainder: MR2=0; {MR0 and MR1 previous set}
MY0=AX0, AR=PASS AY0; {Divisor in MYO, Quotient in AR}
MR=MR-AR*MY0 (UU); {Determine remainder}
RTS; {Return to calling program}
.ENDMOD;
Listing B.1 Division Error Routine