;This program checks to see if a number is prime or not.  If it isn't,
;output the smallest divisor.
;Input : 200h
;Output: 201h = 0 if the number is prime, otherwise the smallest divisor
        mov al, byte ptr 200h
        mov bl, 2                       ;the possible divisor
outr:   cmp al, bl                      ;check for generated prime
        je  prime
        mov cl, 0                       ;accum for sum of divisors
innr:   add cl, bl                      ; divisor gets accumulated
        jc  next
        cmp cl, al                      ;if equal, bl is divisor of al
        je  nonprime
        jb  innr
next:   add bl, 1                       ;setup for next divisor
        cmp bl, 3                       ;special check for 2 -> 3
        je  outr
        add bl, 1
        cmp bl, 15                      ;check for sqrt of 256
        jbe outr
;tried all of the divisors, it's gotta be prime!
prime:  mov byte ptr 201h, 0
nonprime: mov byte ptr 201h, bl