// Input number; output its residue mod 2 INP // read input into accumulator loop1 STA save_acc // save accumulator (see note below) SUB k128 // keep subtracting 128 until acc < 0 BRP loop1 LDA save_acc // save_acc holds a number in range 0..127 loop2 STA save_acc SUB k16 // keep subtracting 16 until acc < 0 BRP loop2 LDA save_acc // save_acc holds a number in range 0..15 loop3 STA save_acc SUB k2 // keep subtracting 2 until acc < 0 BRP loop3 LDA save_acc // save_acc holds 0 or 1, the result write OUT // output result HLT k2 DAT 2 k16 DAT 16 k128 DAT 128 save_acc DAT // end