E556GB — 6.15.10 Binary 16-bit divider

Examples 6.15.10 Binary 16-bit divider HB LB Z1: dividend 16 bit 0-65535 ($FFFF) BM00.01+ BM00.00 Z2: divisor 16 bit 0-65535 ($FFFF) BM00.03+ BM00.02 Z3: quotient 16 bit 0-65535 ($FFFF) BM00.05+ BM00.04 HB: high byte HB LB LB: + Z1 HB LB BM00.03 + BM00.02 Z2 Z3 BM00.05 + BM00.04 Binary divider Programm LD BM00.00 ;Z1 dividend DIVD BM00.02 ;Z2 divisor =D BM00.04 ;Z3 quotient The resulting quotient is an integer number. Proceed as follows to find the rest: LD BM00.04 ;Z3 quotient MULD BM00.02 ;Z2 divisor =D LBM00.00 ;Z3(integer!) *Z2 LD BM00.00 ;Z1 dividend SUBD LBM00.00 =D BM00.06 ;rest 139