;;--------------------------------------------------------60
;; Last: 8:02 AM 4/7/2008  By: s_dubrovich@yahoo.com
;;
;; assembler control constructs -8086
;;
;;A.0. [Conditional Jumps, which test flags and registers (CX only)]
;;	Flag	Meaning
;;	ZF	Zero Flag
;;	SF	Sign
;;	OF	Overflow
;;	CF	Carry
;;	PF	Parity
;;
;;	[AF]	Auxiliary - BCD arithmetic instructions only.
;;
;;A. For Comparisons Use Less/Greater for Signed Numbers [ZF,SF], Above/Below
;;  for Unsigned Numbers [ZF,CF].
;;
;;A.A. Since Jumps on Comparison are short jumps, -128 to 127 bytes away, use
;;  an unconditional jmp, with a test for the opposite condition to short jmp
;;  over the unconditional jmp.  This distance is because of the encoding of
;;  a one byte signed offset of the destination from the next instruction's
;;  Location.  The end of the conditional jmp instruction + 1 is the address
;;  to which the signed offset is added.
;;
;; re: If data is invalid [CF=1] then execute error section:
;;	JNC  L1              ;Test for Opposite State, CF=0
;;	JMP  INVALID_HANDLER
;; L1:
;; ---
;;A.B. Use Jumps to implement one of alternate or repetitive constructs.
;; re: if AX=0 then add 6 to BX, else add 9 to CX.
;;
;;	CMP  AX,0
;;	JE   L1		;IF
;;	JNE  L2
;; L1:			;THEN
;; 	ADD  BX,6
;;	JMP  L3
;; L2:			;ELSE
;;	ADD  CX,9
;; L3:
;; ---
;;A.C Looping instructions use CX=0 as a loop limit, auto-decrementing on 
;;     each iteration, exiting the loop when CX=0, or, exiting the loop
;;     on the ZF state as a result of a CMP...
;;	LOOP	;while CX nonzero
;;	LOOPE	;while if equal, CX nonzero & ZF=1. [LOOPZ]
;;	LOOPNE	;while if not equal, CX nonzero & ZF=0. [LOOPNZ]
;;
;; ---
;;B. Fundamental Flow Control Constructs: Sequence, Alternation, Repetition.
;; I.
;;    Sequence - One of three fundamental, instruction flow control, constructs.
;;	Sequence is the Processor Default State.  The execution of a series of
;;	instructions, one after another.  A series of instructions with a limit
;;	is called a Block.
;; II.
;;    Alternation - The execution of one, of more than one, Sequence Block,
;;	dependant on the state of a specified condition. (Selection).
;;      Ex. GOTO, IF..THEN, IF..THEN..ELSE
;; III.
;;    Repetition - The execution of a Sequence Block over and over, until 
;;	[or while] a specified state holds true.
;;      Ex. FOR, WHILE, REPEAT, DO Loops
;; IV.
;;    Recursion - Reentry of a Procedure while it is still active.  Requires
;;      parameters to be within an activation record, (Stack Frame), so that
;;      procedure can be reentrant without overwriting or losing parameter
;;      values.
;; V.
;;    Coroutine -
;;
;;---------
;;B.II.
;;
;; The CASE Construct:	<-- Alternation Construct.
;;			;case State1: DO Blk1,
;;			;     State2: DO Blk2,
;;			;     State3: DO Blk3,
;;	CMP  State,State1
;;	JE   L1
;;	CMP  State,State2
;;	JE   L2
;;	CMP  State,State3
;;	JE   L3
;;	JMP  L4		;none of the above in this case [|ELSE]
;; L1:
;;	[BLK1]
;;	JMP  L4 [|IF.ELSE JMP L5]
;; L2:
;;	[BLK2]
;;	JMP  L4 [|IF.ELSE JMP L5]
;; L3:
;;	[BLK3]
;;		[|IF.ELSE JMP L5]
;; L4:  [ELSE.BLK]
;; L5:  	[IF.ELSE]
;;----
;; The IF-THEN-ELSE Construct  <-- Alternation Construct
;;	IF State THEN 		;CASE-ELSE with One State Check
;;		Blk1
;;	ELSE
;;		Blk2
;; ;if State1.GT Blk1, else Blk2
;;	CMP  STATE,STATE1
;;	JG   L1
;;	JMP  L2
;; L1:			;cond.
;;	[BLK1]
;;	JMP  L3
;; L2:			;Else
;;	[BLK2]
;; L3:
;;
;;----
;; The IF-THEN Construct  <-- Alternation Construct
;;
;; ;if cond then seq.
;;	CMP  State,State1
;;	JNE_State1 L2
;; L1:
;;	[BLK1]
;; L2:
;;
;;---------
;;B.III.
;;
;; The REPEAT-UNTIL Construct  <-- Repetition Construct
;;	;; repeat seq until condition, cond can be T..F based
;;	;; on CF (JC) or AX set to 0 or 1. (JNE).
;;	REPEAT Blk1
;;	UNTIL  State1  ;condition
;;  ;repeat seq until cond.
;;
;; L1:
;;	[BLK1]		;;Note: executes at least once!
;;	CMP State,State1
;;	JN_State L1
;;
;;	;; Also, using CX & Loop..
;;--[alternate, with repeat limit, using CX & Loop]
;;  ;repeat seq N times.
;;	MOV  CX,N
;; L1:
;;	[BLK1]
;;	LOOP L1		;;Also LOOPNE,LOOPE,LOOPNZ,LOOPZ
;;
;;--[alternate, with repeat limit, using CX & Loop, Also Cond]
;;  ;; repeat seq Until (Cond or N times).
;;	MOV  CX,N
;; L1:
;;	[BLK1]
;;	CMP  State,State1
;;	LOOPNE L1
;;----
;;
;; The WHILE-REPEAT Construct  <-- Repetition Construct 
;;  ;; while cond repeat seq
;;  Note: might not execute seq!
;; L1:
;;	CMP  State,State1
;;	JN_State L2
;;	[BLK1]
;;	JMP  L1
;; L2:
;;- - - - - - eof - - - - - - -
;;--------------------------------------------------------60