;divide two numbers
;input 500h and 501h
;output  502h = div
;        503h = mod
;        504h = error
;
        mov     al, byte ptr 500h        ;get input
        mov     ah, byte ptr 501h
        cmp     ah, 0                    ;check error (div by 0)
        je      error
;else div is OK
        mov     byte ptr 504h, 0        ; div is OK
        mov     byte ptr 502h, 0        ; count starts at zero = div of num
around: cmp     al, ah
        jb      fini
        sub     al, ah
        add     byte ptr 502h, 1        ; able to sub one more!!
        jmp     around
fini:   mov     byte ptr 503h, al       ; the mod
        hlt
error:  mov     byte ptr 504h, 1        ;yes, error happened
        hlt
        end