IN G
IN H

IN D

MOV F 1
CMP D F
JZ 15

IN A
IN B

MOV C 0

LOAD A E
ADD C E

ADD A F
CMP B A
JZ 12

JNZ 9

OUT C

SUB H F
CMP H F
JZ 29

JNZ 3

IN A
IN B
IN E

LOAD A F
ADD F E
STORE A F

ADD A H
CMP B A
JZ 24

JNZ 20

SUB H F
CMP H F
JZ 29

JNZ 3

RETURN