home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
simtel
/
sigm
/
vols200
/
vol200
/
z3lib2.hlp
< prev
next >
Wrap
Text File
|
1994-07-13
|
6KB
|
201 lines
Introduction ZCPR3 Flow Control
End IF IFEND
Raise IF IFT/IFF
Test IF IFTEST
Toggle IF IFELSE
:Introduction to ZCPR3 Flow Control
Basic Defintion of Flow Control:
Al∞ commanΣ sequence≤ issued unde≥ ZCPR│ caε bσ though⌠ ì
t∩á executσá withiεá ß TRU┼ flo≈ contro∞á state«á Tha⌠á is¼ ì
wheneve≥á ß commanΣ i≤ executeΣ unde≥ ZCPR3¼á thσá statσá oµ ì
flo≈ contro∞ i≤ TRUE« Iµ thσ statσ oµ flo≈ contro∞ i≤ FALS┼ ì
theε n∩ command≤ excep⌠ flo≈ command≤ wil∞ bσ executeΣ unti∞ ì
the state of flow control becomes TRUE.
Background:
Wheε ZCPR│ firs⌠ come≤ up¼ thσ statσ oµ flo≈ contro∞ i≤ ì
alway≤á TRUE«á An∙ commanΣ issueΣ wil∞ bσ executed«á Iµá ß ì
Flo≈áá CommanΣá Packagσá i≤á installeΣá whicΦá support≤á thσ ì
IF/ELSE/F╔ (EnΣ IF⌐ commands¼ theε thσ statσ oµ flo≈ contro∞ ì
caε bσ changeΣ b∙ use≥ commands« Fo≥ example¼ thσ followinτ ì
terminal session illustrates:
SCR>; any command will execute now
SCR>era *.bak
No Files
SCR>dir
MYFILE .TXT | OBJECT .BIN
SCR>; we can set a flow control state to be false
SCR>IF F
IF F
SCR>; no command will execute now
SCR>dir
SCR>else
IF T
SCR>dir
MYFILE .TXT | OBJECT .BIN
SCR>FI
No IF
SCR>
Hence¼áá wheεá an∙á commanΣá i≤á executed¼á beforσá thσ ì
executioεá actuall∙ begins¼á ZCPR│ wil∞ looδ t∩ seσá iµá thσ ì
statσ oµ thσ flo≈ contro∞ i≤ TRUE« SucΦ i≤ thσ casσ wheε wσ ì
arσá no⌠ withiε aε I╞ conditioε o≥ wheε wσ arσ withiε onσ o≥ ì
more IF conditions, all of which are TRUE.
ZCPR│ allow≤ thσ use≥ t∩ bσ nesteΣ int∩ IF≤ u≡ t∩ eigh⌠ ì
(8⌐á level≤ deep«á Tha⌠ is¼á thσ structurσ oµá hi≤á commanΣ ì
sequence≤á caε takσ thσ forφ oµ somethinτ likσ thσ followinτ ì
which can be nested into 8 levels of IFs:
<set of commands>
IF T
<set of commands>
IF T
<set of commands>
IF T
<set of commands>
FI
<set of commands>
ELSE
<set of non-executed commands>
IF T
<set of non-executed commands>
FI
FI
ELSE
<set of non-executed commands>
FI
CommanΣá structure≤ likσ thosσ presenteΣ abovσ arσá no≈ ì
possiblσ unde≥ ZCPR3«á Essentially¼á ZCPR│ command≤ caε no≈ ì
take the form of a programming language in their own right.
Thσ se⌠ oµ routine≤ availablσ iε thi≤ par⌠ oµ Z3LI┬ arσ ì
useΣ t∩ providσ thσ programme≥ ß simplσ interfacσ t∩ contro∞ ì
thσ flo≈ contro∞ withiε (anΣ outside⌐ hi≤ program«á Hσ can¼ ì
unde≥ hi≤ owε control¼á issuσ command≤ t∩:
« ente≥ thσ nex⌠ I╞ leve∞ iε ß TRU┼ o≥ FALS┼ condition,
. toggle the state of the current IF level,
. drop down to the previous IF level,
. determine the current IF level number,
. or multiples of the above
:End IF Level
Z3LIB Routine: IFEND
Function:
Dro≡á t∩á thσá previou≤ I╞ level«á Iµ thσá prograφá i≤ ì
currentl∙ withiε onσ o≥ morσ IFs¼á IFEN─ wil∞ dro≡ i⌠ t∩ thσ ì
next IF level down, terminating the current IF level.
Naturally¼á fo≥ ß transien⌠ t∩ bσ executinτ now¼á therσ ì
i≤á currentl∙á eithe≥ n∩ I╞ leve∞ o≥ therσ i≤á ßá TRU┼á flo≈ ì
contro∞á statσ (al∞ preceedinτ IF≤ arσ TRUE)«á Iµ wσ arσ a⌠ ì
somσá I╞ level¼á callinτ IFEN─ drop≤ u≤ int∩ thσá preceedinτ ì
one.
Inputs: None
Outputs: A=0 and Zero Flag Set (Z) if no IF level
A=0FFH and NZ if IFEND is successful
Registers Affected: PSW
Side Effects: None
Special Error Conditions: None
:Raise IF
Z3LIB Routine: IFT/IFF
Function:
Raisσ thσ flo≈ contro∞ statσ int∩ thσ nex⌠ leve∞ oµ IF« ì
IF╘á raise≤á thσ statσ int∩ thσ nex⌠ leve∞ anΣá set≤á i⌠á t∩ ì
TRUE¼á whilσá IF╞á raise≤ thσ statσ int∩ thσ nex⌠ leve∞á anΣ ì
sets it to FALSE.
Thσ flo≈ contro∞ statσ caε suppor⌠ eigh⌠ (8⌐ level≤á oµ ì
IFs¼á anΣá IF╘á anΣ IF╞ returε erro≥ code≤ indicatinτ iµá aε ì
overflo≈á (anΣ subsequen⌠ failurσ t∩ ente≥ thσá nex⌠á state⌐ ì
occurred.
Inputs: None
Outputs: A=0 and Zero Flag Set (Z) if IF level overflow
A=0FFH and NZ if IF level OK
Registers Affected: PSW
Side Effects: None
Special Error Conditions: None
:Test IF
Z3LIB Routine: IFTEST
Function:
T∩á determinσ thσ curren⌠ I╞ level«á IFTES╘ return≤á ß ì
valuσ froφ ░ t∩ ╕ iε thσ ┴ register¼á indicatinτ thσ curren⌠ ì
I╞ level« Iµ A=0¼ therσ i≤ n∩ curren⌠ IF« Thσ Zer∩ Flaτ i≤ ì
set accordingly, so the following can be done:
ext IFTEST
...
call iftest ;get IF level
jz noif ;process if not any IF level
cpi 8 ;test for max IF level
jz atmax ;process if at max IF level
...
Inputs: None
Outputs: A = number of current IF level, Zero Flag set
accordingly
Registers Affected: PSW
Side Effects: None
Special Error Conditions: None
:Toggle IF
Z3LIB Routine: IFELSE
Function:
Togglσá thσá TRUE/FALS┼ statσ oµ thσ curren⌠ I╞á level« ì
I╞ thσ prograφ i≤ currentl∙ withiε aε I╞ leve∞ (theε i⌠ MUS╘ ì
bσ withiε ß TRU┼ I╞ level)¼ callinτ IFELS┼ (aε odΣ numbe≥ oµ ì
times⌐ toggle≤ thσ I╞ leve∞ t∩ FALSE«á Tw∩ call≤ t∩á IFELS┼ ì
(an∙á eveε numbe≥ oµ calls⌐ resul⌠ iε thσ I╞ leve∞ remaininτ ì
a⌠ TRUE.
Inputs: None
Outputs: A=0 and Zero Flag Set (Z) if no current IF
A=0FFH and NZ if successful
Registers Affected: PSW
Side Effects: None
Special Error Conditions: None