multdiv.inc


Author: Jonathan Weaver, jonw0224@netscape.net
Date: 2/6/2010
Version: 1.0
Filename: multdiv.inc
Description: A multiply and a divide routine

External Variable List


;external cnt cnt is a temporary counter variable used by MultBB and DivideIB. Declare register in main program.
;external multA multA is used as a multiplier by multBB and divisor by DivideIB. Declare register in main program.
;external multB multB is used as a multiplier by MultBB and as a quotient by DivideIB. Declare register in main program.
;external prodH prodH is the upper byte of a two byte variable. It is the product of MultBB and the dividend of DivideIB. Declare register in main program.
;external prodL prodL is the lower byte of a two byte variable. It is the product of MultBB and the dividend of DivideIB. Declare register in main program.


Procedure Heading List


DivideIB
MultBB


Procedure Descriptions


DivideIB
Description:
Divide Routine. Returns prodH:prodL / multA as multB and prodH:prodL MOD multA as prodH. Affects WREG and STATUS. Requires 96 Cycles to execute and 16 program words. Compiles if _DivideIB is defined.
Parameters:
multA one byte divisor. Expects multA to be less than 128 (positive).
prodH upper byte of a 16 bit dividend. Expects prodH
prodL lower byte of a 16 bit dividend. Routine destroys prodL.
multB single byte quotient
cnt internal variable used as a counter


MultBB
Description:
Multiply Routine. Returns multA*multB as 16 bit prodH:prodL. Destroys multB. Affects WREG and STATUS. Requires 71 cycles to execute and 14 program words. Compiles if _MultBB is defined.
Parameters:
multA register to multiply by multB
multB register to multiply by multA
prodH upper byte of product
prodL lower byte of product
cnt internal variable used as a counter