; ; SUB: A = A - B ; LD A, 01110001B ; 71D (packed BCD) LD B, 01010100B ; 54D (packed BCD) OUT (00H), A ; Set LEDs in 00H with 1st operand LD C, 01H OUT (C), B ; Set LEDs in 01H B with 2nd operand SUB B ; B is substracted from A, and the result is written back to A OUT (02H), A ; Send result (expect 0001 1101 = 1DH) of A - B to 02H ; ; The A register is BCD corrected using the contents of the flags. ; See: http://z80-heaven.wikidot.com/instructions-set:daa ; DAA ; A register is BCD corrected using the contents of the Flags OUT (03H), A ; Set LEDs in 03H with content DAA result, expect 0001 0111 = 17D