;This program determines whether a byte is even or odd
;Programmed in class by Nathan Hull
;Note:  This version has a logic bug in it that you are asked to
;        locate before the next class!
;
;Input = byte ptr 300h
;Output = byte ptr 301h
;           = 1 if input is odd
;           = 2 if input is even
            mov al, byte ptr 300h    ;get the input from memory
submore:    sub al, 2                ;decide if 2-1=0 or 1-1=FF
            jc  odd                  ;   happens first, i.e., either
            jz  even                 ;   the carry or zero flag comes on
            jmp submore              ;neither has come on - more to sub
odd:        mov byte ptr 301h, 1     ; it was an odd number!
            hlt
even:       mov byte ptr 301h, 2     ; it was an even number!
            hlt
            end