Re-arranging it a bit (I'm not sure if it'll help, but I do this sometimes to understand it better myself):
Code:
LDY #0
BEGIN
LDX $program,Y
INY
LDA $program,Y
IF_ZERO
CPX #0 ; If second byte is zero: (This was label zero2.)
IF_EQ
LDA 0 ; Both bytes were zero. (This was label zero3.)
IF_NOT_ZERO
INY
LDA $program,Y ; Y is PC so modify that.
TAY ; For simplicity, I limited it to 256 bytes of code.
END_IF
ELSE_
LDA (0,X)
INY
ADC $program,Y
INY
SBC $program,Y
CMP (0,X)
IF_EQ
LDA $program,Y ; Store value if both ADD and SUB are zero.
END_IF
STA (0,X)
INY
END_IF
ELSE_
CPX #0
IF_EQ
TAX ; If first byte is zero: (This was label zero1.)
INY
LDA $program,Y
STA (0,X) ; Save LSB into register.
INY
INX
LDA $program,Y
STA (0,X) ; Save MSB into register.
INY
ELSE_
STA 0 ; Save second register.
LDA (0,X) ; Move data from address in first register.
LDX 0
STA (0,X) ; Move data to address in second register.
INY
END_IF
END_IF
AGAIN
program: data $01, $02, $03, $04, and so on....