; 8 bit division... Flags
; JZ  - Jump if subtrahend is equal to minuend      or JE
; JC  - Jump if subtrahend is less than minuend     or JL
; JNC - Jump if subtrahend is greater than minuend  or JG
0000  10 00 3A           LOD A,[Dividend]
0003  11 00 3D           STO [Remainder],A  ; Remainder is initially dividend
0006  10 00 3E           LOD A,[Zero]
0009  11 00 3C           STO [Quotient],A   ; Quotient is initially zero
000C  10 00 3D Subtract  LOD A,[Remainder]  ; Subtract the divisor from the remainder
000F  21 00 3B           SUB A,[Divisor]
0012  11 00 3D           STO [Remainder],A
0015  34 00 27           JNC Add            ; If result less than zero, undo it
0018  31 00 30           JZ  Finish         ; If result is zero, increment quotient final time
001B  10 00 3C           LOD A,[Quotient]   ; Count the subtraction (increment quotient)
001E  20 00 3F           ADD A,[One]
0021  11 00 3C           STO [Quotient],A
0024  30 00 0C           JMP Subtract       ; Go do it again.
0027  20 00 3B Add       ADD A,[Divisor]    ; Undo last subtraction
002A  11 00 3D           STO [Remainder],A
002D  30 00 39           JMP Done           ; We're done
0030  10 00 3C Finish    LOD A,[Quotient]   ; Increment quotient final time.
0033  20 00 3F           ADD A,[One]
0036  11 00 3C           STO [Quotient], A
0039  FF       Done      HLT
003A  09       Dividend  #0A
003B  03       Divisor   #03
003C  00       Quotient  #00 ; Expect 03
003D  00       Remainder #00 ; Expect 01
003E  00       ZERO      #00
003F  01       ONE       #01
