home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols200 / vol200 / z3lib2.hlp < prev    next >
Text File  |  1994-07-13  |  6KB  |  201 lines

  1. Introduction   ZCPR3 Flow Control
  2. End IF         IFEND
  3. Raise IF       IFT/IFF
  4. Test IF        IFTEST
  5. Toggle IF      IFELSE
  6. :Introduction to ZCPR3 Flow Control
  7.  
  8. Basic Defintion of Flow Control:
  9.  
  10.      Al∞ commanΣ sequence≤ issued unde≥ ZCPR│ caε bσ though⌠ ì
  11. t∩á executσá withiεá ß TRU┼ flo≈ contro∞á state«á  Tha⌠á is¼ ì
  12. wheneve≥á ß commanΣ i≤ executeΣ unde≥ ZCPR3¼á thσá statσá oµ ì
  13. flo≈ contro∞ i≤ TRUE«  Iµ thσ statσ oµ flo≈ contro∞ i≤ FALS┼ ì
  14. theε n∩ command≤ excep⌠ flo≈ command≤ wil∞ bσ executeΣ unti∞ ì
  15. the state of flow control becomes TRUE.
  16.  
  17. Background:
  18.  
  19.      Wheε ZCPR│ firs⌠ come≤ up¼ thσ statσ oµ flo≈ contro∞ i≤ ì
  20. alway≤á TRUE«á  An∙ commanΣ issueΣ wil∞ bσ executed«á  Iµá ß ì
  21. Flo≈áá CommanΣá Packagσá i≤á installeΣá whicΦá support≤á thσ ì
  22. IF/ELSE/F╔ (EnΣ IF⌐ commands¼ theε thσ statσ oµ flo≈ contro∞ ì
  23. caε bσ changeΣ b∙ use≥ commands«  Fo≥ example¼ thσ followinτ ì
  24. terminal session illustrates:
  25.  
  26.  
  27. SCR>; any command will execute now
  28. SCR>era *.bak
  29. No Files
  30. SCR>dir
  31. MYFILE  .TXT  |  OBJECT  .BIN
  32. SCR>; we can set a flow control state to be false
  33. SCR>IF F
  34.  IF F
  35. SCR>; no command will execute now
  36. SCR>dir
  37. SCR>else
  38.  IF T
  39. SCR>dir
  40. MYFILE  .TXT  |  OBJECT  .BIN
  41. SCR>FI
  42.  No IF
  43. SCR>
  44.  
  45.  
  46.      Hence¼áá wheεá an∙á commanΣá i≤á executed¼á beforσá thσ ì
  47. executioεá actuall∙ begins¼á ZCPR│ wil∞ looδ t∩ seσá iµá thσ ì
  48. statσ oµ thσ flo≈ contro∞ i≤ TRUE«  SucΦ i≤ thσ casσ wheε wσ ì
  49. arσá no⌠ withiε aε I╞ conditioε o≥ wheε wσ arσ withiε onσ o≥ ì
  50. more IF conditions, all of which are TRUE.
  51.  
  52.      ZCPR│ allow≤ thσ use≥ t∩ bσ nesteΣ int∩ IF≤ u≡ t∩ eigh⌠ ì
  53. (8⌐á level≤ deep«á  Tha⌠ is¼á thσ structurσ oµá hi≤á commanΣ ì
  54. sequence≤á caε takσ thσ forφ oµ somethinτ likσ thσ followinτ ì
  55. which can be nested into 8 levels of IFs:
  56.  
  57.  
  58. <set of commands>
  59. IF T
  60.      <set of commands>
  61.      IF T
  62.           <set of commands>
  63.           IF T
  64.                <set of commands>
  65.           FI
  66.           <set of commands>
  67.      ELSE
  68.           <set of non-executed commands>
  69.           IF T
  70.                <set of non-executed commands>
  71.           FI
  72.      FI
  73. ELSE
  74.      <set of non-executed commands>
  75. FI
  76.  
  77.  
  78.      CommanΣá structure≤ likσ thosσ presenteΣ abovσ arσá no≈ ì
  79. possiblσ unde≥ ZCPR3«á  Essentially¼á ZCPR│ command≤ caε no≈ ì
  80. take the form of a programming language in their own right.     
  81.  
  82.      Thσ se⌠ oµ routine≤ availablσ iε thi≤ par⌠ oµ Z3LI┬ arσ ì
  83. useΣ t∩ providσ thσ programme≥ ß simplσ interfacσ t∩ contro∞ ì
  84. thσ flo≈ contro∞ withiε (anΣ outside⌐ hi≤ program«á  Hσ can¼ ì
  85. unde≥ hi≤ owε control¼á issuσ command≤ t∩:
  86.  
  87.      « ente≥ thσ nex⌠ I╞ leve∞ iε ß TRU┼ o≥ FALS┼ condition,
  88.      . toggle the state of the current IF level,
  89.      . drop down to the previous IF level,
  90.      . determine the current IF level number,
  91.      . or multiples of the above
  92.  
  93.  
  94. :End IF Level
  95.  
  96. Z3LIB Routine: IFEND
  97.  
  98. Function:
  99.      Dro≡á t∩á thσá previou≤ I╞ level«á  Iµ thσá prograφá i≤ ì
  100. currentl∙ withiε onσ o≥ morσ IFs¼á IFEN─ wil∞ dro≡ i⌠ t∩ thσ ì
  101. next IF level down, terminating the current IF level.
  102.  
  103.      Naturally¼á fo≥ ß transien⌠ t∩ bσ executinτ now¼á therσ ì
  104. i≤á currentl∙á eithe≥ n∩ I╞ leve∞ o≥ therσ i≤á ßá TRU┼á flo≈ ì
  105. contro∞á statσ (al∞ preceedinτ IF≤ arσ TRUE)«á  Iµ wσ arσ a⌠ ì
  106. somσá I╞ level¼á callinτ IFEN─ drop≤ u≤ int∩ thσá preceedinτ ì
  107. one.
  108.  
  109. Inputs: None
  110.  
  111. Outputs: A=0 and Zero Flag Set (Z) if no IF level
  112.           A=0FFH and NZ if IFEND is successful
  113.  
  114.  
  115. Registers Affected: PSW
  116.  
  117. Side Effects: None
  118.  
  119. Special Error Conditions: None
  120.  
  121. :Raise IF
  122.  
  123. Z3LIB Routine: IFT/IFF
  124.  
  125. Function:
  126.      Raisσ thσ flo≈ contro∞ statσ int∩ thσ nex⌠ leve∞ oµ IF«  ì
  127. IF╘á raise≤á thσ statσ int∩ thσ nex⌠ leve∞ anΣá set≤á i⌠á t∩ ì
  128. TRUE¼á whilσá IF╞á raise≤ thσ statσ int∩ thσ nex⌠ leve∞á anΣ ì
  129. sets it to FALSE.
  130.  
  131.      Thσ flo≈ contro∞ statσ caε suppor⌠ eigh⌠ (8⌐ level≤á oµ ì
  132. IFs¼á anΣá IF╘á anΣ IF╞ returε erro≥ code≤ indicatinτ iµá aε ì
  133. overflo≈á (anΣ subsequen⌠ failurσ t∩ ente≥ thσá nex⌠á state⌐ ì
  134. occurred.
  135.  
  136. Inputs: None
  137.  
  138. Outputs: A=0 and Zero Flag Set (Z) if IF level overflow
  139.           A=0FFH and NZ if IF level OK
  140.  
  141.  
  142. Registers Affected: PSW
  143.  
  144. Side Effects: None
  145.  
  146. Special Error Conditions: None
  147.  
  148. :Test IF
  149.  
  150. Z3LIB Routine: IFTEST
  151.  
  152. Function:
  153.      T∩á determinσ thσ curren⌠ I╞ level«á  IFTES╘ return≤á ß ì
  154. valuσ froφ ░ t∩ ╕ iε thσ ┴ register¼á indicatinτ thσ curren⌠ ì
  155. I╞ level«  Iµ A=0¼ therσ i≤ n∩ curren⌠ IF«  Thσ Zer∩ Flaτ i≤ ì
  156. set accordingly, so the following can be done:
  157.  
  158.           ext  IFTEST
  159.           ...
  160.           call iftest    ;get IF level
  161.           jz   noif      ;process if not any IF level
  162.           cpi  8         ;test for max IF level
  163.           jz   atmax     ;process if at max IF level
  164.           ...
  165.  
  166. Inputs: None
  167.  
  168.  
  169. Outputs: A = number of current IF level, Zero Flag set
  170.                accordingly
  171.  
  172. Registers Affected: PSW
  173.  
  174. Side Effects: None
  175.  
  176. Special Error Conditions: None
  177.  
  178. :Toggle IF
  179.  
  180. Z3LIB Routine: IFELSE
  181.  
  182. Function:
  183.      Togglσá thσá TRUE/FALS┼ statσ oµ thσ curren⌠ I╞á level«  ì
  184. I╞ thσ prograφ i≤ currentl∙ withiε aε I╞ leve∞ (theε i⌠ MUS╘ ì
  185. bσ withiε ß TRU┼ I╞ level)¼ callinτ IFELS┼ (aε odΣ numbe≥ oµ ì
  186. times⌐ toggle≤ thσ I╞ leve∞ t∩ FALSE«á  Tw∩ call≤ t∩á IFELS┼ ì
  187. (an∙á eveε numbe≥ oµ calls⌐ resul⌠ iε thσ I╞ leve∞ remaininτ ì
  188. a⌠ TRUE.
  189.  
  190. Inputs: None
  191.  
  192. Outputs: A=0 and Zero Flag Set (Z) if no current IF
  193.           A=0FFH and NZ if successful
  194.  
  195.  
  196. Registers Affected: PSW
  197.  
  198. Side Effects: None
  199.  
  200. Special Error Conditions: None
  201.