I am familiar with Wil Baden's short-circuit boolean evaluation using ANDIF and ORIF (which I suspect would be better called ORELSE).
: ANDIF S" DUP IF DROP " EVALUATE ; IMMEDIATE
: ORIF S" DUP 0= IF DROP " EVALUATE ; IMMEDIATE
But these don't lend themselves to use in assembly-language where we typically don't evaluate a boolean result to feed to a conditional, instead we directly short-circuit the control-flow based on condition codes like Z, NZ, C, NC etc.
I figured out a way to do this, and it can be used in Forth as well as assembler. It can be done in ANS Forth and makes no assumptions about the implementation of the control-flow stack. I think the hardest part was coming up with a name for
1 CS-ROLL THEN (i.e. CS-SWAP THEN)
If you replace THEN with ENDIF it's not quite so difficult.
: ENDIF POSTPONE THEN ; IMMEDIATE
: END-PRIOR-IF 1 CS-ROLL POSTPONE ENDIF ; IMMEDIATE
The equivalent of the C-like short-circuit OR conditional
IF (p || q || r) doThis ELSE doTheOther ENDIF
is then written with overlapping structures as
p 0= IF
q 0= IF
r IF
END-PRIOR-IF \ endif not q
END-PRIOR-IF \ endif not p
doThis
ELSE \ else r
doTheOther
ENDIF \ endif r
Note the inversion of all but the last condition in the short-circuit OR.
The equivalent of the C-like short-circuit AND conditional
IF (p && q && r) doThis ELSE doTheOther ENDIF
is written as
p IF
q IF
r IF
doThis
ELSE \ else r
END-PRIOR-IF \ endif q
END-PRIOR-IF \ endif p
doTheOther
ENDIF \ endif r
Note that the END-PRIOR-IFs come after the ELSE in the short-circuit AND, whereas they come after the IF in the short-circuit OR.
I don't know how to enforce multiple spaces and hence indentation in this forum, so it's probably lost above, but you can see the intended indentation, and read about the assembly-language application, here:
http://dkeenan.com/AddingStructuredControlFlowToAnyAssembler2.htm
Admittedly Wil Baden's ANDIF and ORIF (or ORELSE) are a lot more readable and don't involve overlapping structures, but I don't see any way of doing the equivalent for assembly language condition codes.