Safe Division
Divides the value at register R0 by the value at register R1. The quotient is stored in R0 and the remainder in R1. The value of the B register remains unchanged.
; +-----------------------------------------------------------------+; | subroutine: SAFE_DIV |; | 8-Bit / 8-Bit to 8-Bit Quotient & Remainder Unsigned Divide |; | |; | input: R00 = Dividend X |; | R01 = Divisor Y |; | |; | output: R00 = quotient Q of division ( Q = X / Y ) |; | R01 = remainder R of division ( R = X % Y ) |; | |; | alters: Carry Flag (C) |; | |; | notes: If division by zero is attempted nothing happens |; | and the Overflow Flag (OV) is not altered. |; +-----------------------------------------------------------------+SAFE_DIV:JZR01SADI_END; Avoid division by zeroPUSHB; Save contents of B registerDIVR00R01MOVR01BPOPB; Restore B register to previous valueSADI_END:RET