;This program determines whether a byte is even or odd
;Programmed in class by Nathan Hull
;corrected version
;
;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
		     sub al, 0			      ;the correction - catch zero as even
			  jz  even
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