home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / C128CPM / SALIAS16.LBR / ALIAS.NZT / ALIAS.NOT
Encoding:
Text File  |  1990-10-01  |  10.1 KB  |  244 lines

  1.  
  2.                             Alia≤ 1.5
  3.                  b∙ Joσ Wrigh⌠  ▒ Septembe≥ 1990
  4.  
  5.  
  6. ALIAS░ ái≤ thσ actua∞ alia≤ modulσ writteε t∩ disk« I⌠ áha≤ ábeeε ì
  7. enhanceΣ ásomewha⌠ át∩ áallo≈ al∞ fivσ ásysteφ áfilename≤ át∩ ábσ ì
  8. addressed¼ á$F░ beinτ thσ prototypσ SH.VA╥ shel∞ ávariablσ áfile«  ì
  9. Thσ á'Tº áfiletypσ operato≥ wa≤ pu⌠ bacδ iε sucΦ átha⌠ á$T░ áwil∞ ì
  10. poin⌠ át∩ VAR«  Thσ 'Tº variablσ wa≤ removeΣ iε versioε á1.▒ áfo≥ ì
  11. somσ reasoε tha⌠ ╔ don'⌠ understand«  Iε an∙ case¼ ╔ havσ pu⌠ ái⌠ ì
  12. bacδ in.
  13.  
  14. A≤ ábefore¼ áALIA╙ ha≤ onσ 'escapeº character¼ '$º ádollar« á Thσ ì
  15. character≤ followinτ '$º arσ interpreteΣ t∩ mean..
  16.  
  17.      $ε   Wherσ ε varie≤ ░ througΦ 9«
  18.           $░   return≤ thσ NAM┼ oµ thi≤ alia≤ (froφ EXTFCB)
  19.           $▒   return≤ thσ firs⌠ tokeε oε thσ commanΣ line
  20.           $╣   return≤ thσ nintΦ tokeε oε thσ commanΣ line
  21.  
  22. An∙ á$ε whicΦ doe≤ no⌠ havσ ß correspondinτ tokeε return≤ ß áNUL╠ ì
  23. string¼ nothing.
  24.  
  25.      $¬   Thσ entirσ commanΣ linσ withou⌠ furthe≥ translatioε
  26.      $─   Thσ curren⌠ drivσ letter
  27.      $╒   Thσ curren⌠ use≥ number
  28.  
  29. Fo≥ áF¼ á╬ anΣ T¼ n=░ i≤ thσ SH.VA╥ filenamσ anΣ n=1..┤ áarσ áthσ ì
  30. standarΣ Systeφ Filσ names.
  31.  
  32.      $Fε  Systeφ Filσ ε Namσ anΣ Typσ a≤ NAME.TY╨    (ε i≤ 0..4)
  33.      $Nε  Systeφ Filσ ε Namσ a≤ simpl∙ NAM┼          (ε i≤ 0..4)
  34.      $Tε  Systeφ Filσ ε Typσ a≤ simpl∙ TY╨           (ε i≤ 0..4)
  35.      $ñ   Simpl∙ returε onσ '$º t∩ thσ commanΣ line
  36.  
  37. ALIAS1╡ implemen⌠s ß ne≈ Pointe≥ paramete≥ whicΦ wil∞ expanΣ t∩ ß ì
  38. hexadecima∞ áaddress«  Thσ Pointe≥ wil∞ allo≈ acces≤ át∩ ádynamiπ ì
  39. memor∙ value≤ withiε ß knowε datß structurσ (thσ basσ pagσ o≥ thσ ì
  40. environmen⌠ descriptor¼ ß jum≡ table¼ etc.)«  
  41.  
  42.                 Syntax║  $.ADDR[[[.OFF].OFF]+OFF]
  43.  
  44. Thσ alia≤ paramete≥ i≤ formeΣ witΦ ß '$º followeΣ b∙ ß '.º ápoin⌠ ì
  45. followeΣ b∙ aε address«  Oε expansion¼ i⌠ wil∞ returε thσ WorΣ a⌠ ì
  46. thσ áaddress« á Fo≥ áexample¼ á'$.6º wil∞ áreturε áthσ ávaluσ áiε ì
  47. location≤ á╢ áanΣ á╖ oµ thσ basσ ápage¼ áthσ á'protecteΣ ámemoryº ì
  48. address¼ somethinτ likσ C70╢ o≥ whateve≥ thσ BDO╙ entr∙ is«  
  49.  
  50. Wσ caε als∩ finΣ thσ Z│ Environment«  Thσ alia≤ itselµ i≤ ß ZCPR│ ì
  51. Typσ á▒ filσ witΦ ß standarΣ Z│ header«  Thσ addres≤ oµ Z3EN╓ ái≤ ì
  52. alway≤ áa⌠ 109Φ iε sucΦ ß file«  Thσ forφ '$.109º wil∞ expanΣ át∩ ì
  53. thσ he° addres≤ oµ thσ Environmen⌠ (E78░ iε m∙ case).
  54.  
  55. T∩ áfinΣ áaε áaddres≤ iε thσ áEnvironmen⌠ áDescriptor¼ áZ3C╠ áfo≥ ìèexample¼ ááwσ áappenΣ áit≤ áoffset« á '$.109.18º áwil∞ áge⌠ ááthσ ì
  56. environmen⌠ áaddres≤ a⌠ 109h¼ adΣ 18Φ t∩ i⌠ anΣ returε thσ ávaluσ ì
  57. containeΣ áthere¼ áthσ addres≤ oµ Z3C╠ (E90░ iε ám∙ ácase)« á Thσ ì
  58. valuσ áa⌠ Z3C╠ i≤ thσ NXTCH╥ pointer«  Returε thi≤ witΦ onσ ámorσ ì
  59. leve∞ oµ indirectioε a≤ '$.109.18.0'«  
  60.  
  61. $.▒            (0001H⌐        BIOS+│    D50│      (m∙ system)
  62. $.╢            (0006H⌐        BDO╙      C706
  63.  
  64. $.10╣          (0109H⌐        Z3EN╓     E780
  65. $.109.1╕       (Z3ENV+18⌐     Z3C╠      E900
  66. $.109.18.░     (Z3CL⌐         NXTCH╥    E9nn
  67.  
  68. Let'≤ conside≥ thσ Z3MS╟ buffer.
  69.  
  70. $.109.2▓       (Z3ENV+22⌐     Z3MS╟     E880
  71.  
  72. Thσ Erro≥ Addres≤ a⌠ Z3MSG+┤ i≤ returneΣ with..
  73.  
  74. $.109.22.┤     (Z3MSG+4)
  75.  
  76. Thσ pointer≤ caε havσ a≤ man∙ level≤ oµ indirectioε a≤ ánecessar∙ ì
  77. bu⌠ ╔ usuall∙ gσ⌠ los⌠ afte≥ tw∩ o≥ three.
  78.  
  79. Wσ caε als∩ adΣ aε offse⌠ t∩ ß pointer«  Fo≥ example..
  80.  
  81. $.109.22+╢ áwil∞ poin⌠ t∩ thσ Prograφ Erro≥ flaτ a⌠ Z3MSG+6« á O≥ ì
  82. poin⌠ át∩ Systeφ Filσ ▒ iε thσ environmen⌠ witΦ á'$.109+52'« á Wσ ì
  83. caε áusσ thσ '+º o≥ º-º operator≤ t∩ providσ aε offse⌠ áfroφ áthσ ì
  84. memor∙ ávariable«  Fo≥ example¼ '$.1+3º wil∞ returε áBIOS+6¼ áthσ ì
  85. CONS╘ áentr∙ whilσ '$.▒-3º return≤ BIOS+0¼ thσ beginninτ áoµ áthσ ì
  86. bios« á Wσ caε als∩ usσ thi≤ a≤ thσ basi≤ oµ thσ nex⌠ elemen⌠ áiε ì
  87. thσ Pointe≥ parameter«  Anothe≥ example..
  88.  
  89. Thσ Ampr∩ bio≤ i≤ structureΣ sucΦ tha⌠ thσ Disδ Paramete≥ Header≤ ì
  90. oµ áal∞ sixteeε possiblσ drive≤ reside¼ startinτ witΦ áthσ áfirs⌠ ì
  91. flopp∙ drive¼ a⌠ BIOS+80H«  Wσ caε extrac⌠ an∙ oµ thσ pointer≤ iε ì
  92. an∙ oµ thσ header≤ witΦ somσ simplσ math«  Let'≤ ge⌠ thσ áaddres≤ ì
  93. oµ áthσ áSecto≥ Translatσ Tablσ fo≥ drivσ ┼ (4)« á XLAT┼ ái≤ áthσ ì
  94. firs⌠ pointe≥ iε an∙ DPH.
  95.  
  96. Assuminτ NZCOM¼ i⌠ i≤ thσ CBIO╙ wσ arσ interesteΣ in«  ╔ wil∞ ág∩ ì
  97. througΦ thi≤ ste≡ b∙ ste≡ anΣ simplif∙ thing≤ a⌠ thσ end..
  98.  
  99. $.109.▒                  (Z3ENV+1⌐      CBIOS+╢        EA06
  100. $.109.1-╢                CBIOS+6-╢      CBIO╙          EA00 ì
  101. $.109.1-6+8░             CBIOS+8░       CBIOS+8░       EA80
  102. $.109.1-6+80+4░          CBIOS+C0╚      CBIOS+C0╚      EAC0
  103. $.109.1-6+80+40.░        (CBIOS+C0H⌐    EXLAT┼         EC22
  104.  
  105. Wσ simplif∙ thσ matΦ with..
  106.  
  107. $.109.1+BA.░ á anΣ áwσ havσ it«  ╔ aφ no⌠ surσ áho≈ áusefu∞ áthi≤ ì
  108. reall∙ i≤ bu⌠ i⌠ i≤ therσ iµ wσ eve≥ neeΣ it.
  109.  
  110. èThσ alia≤ createΣ b∙ ALIAS1╡ i≤ seveε record≤ long«  Thσ standarΣ ì
  111. alia≤ áwa≤ áeigh⌠ árecord≤ anΣ n∩ alia≤ áma∙ ábσ álonger« á Alia≤ ì
  112. editor≤ iε genera∞ wil∞ rejec⌠ ß filσ oµ ninσ o≥ morσ record≤ anΣ ì
  113. declarσ i⌠ 'No⌠ aε Alias'«  Thi≤ eigh⌠-recorΣ lengtΦ i≤ arbitrar∙ ì
  114. bu⌠ historical«  
  115.  
  116. Thσ alia≤ wil∞ builΣ ß CC╨ commanΣ iε ß loca∞ buffe≥ accordinτ t∩ ì
  117. it≤ áargument≤ anΣ thσ tai∞ passeΣ t∩ i⌠ a≤ i⌠ wa≤ ácalled« á An∙ ì
  118. pendinτ command≤ iε thσ MC╠ wil∞ bσ appendeΣ t∩ thi≤ loca∞ buffe≥ ì
  119. anΣ átheε thσ entirσ buffe≥ copieΣ t∩ thσ beginninτ oµ áthσ áMCL«  ì
  120. Thσ alia≤ theε 'returnsº t∩ thσ CC╨ (ZCPR3⌐ fo≥ execution.ì
  121.  
  122. VALIA╙ áanΣ áSALIA╙ implementeΣ ß Modσ contro∞ iε áthσ áalia≤ áa≤ ì
  123. Norma∞ o≥ Recursive«  Iε Recursivσ Modσ thσ alia≤ wil∞ clea≥ áthσ ì
  124. res⌠ áoµ thσ MC╠ anΣ cop∙ onl∙ it≤ expansioε t∩ thσ beginninτ áoµ ì
  125. thσ áMCL«  BotΦ VALIA╙ anΣ SALIA╙ maintaiε thi≤ flaτ a⌠ á10CΦ áiε ì
  126. thσ áalia≤ a≤ 00Φ iµ Norma∞ anΣ 0FFΦ iµ recursive¼ anΣ ß 46Φ á'Fº ì
  127. characte≥ a⌠ 10Bh«  
  128.  
  129. Thσ commanΣ tai∞ oµ ß giveε alia≤ entr∙ ma∙ bσ n∩ longe≥ thaε 12╢ ì
  130. character≤ becausσ oµ thσ constraint≤ oµ thσ TBUF╞ size«  Iµ áthσ ì
  131. expansioε oµ ß particula≥ alia≤ linσ i≤ longe≥ thaε 12╢ byte≤ áwσ ì
  132. flaτ aε Ovf∞ erro≥ anΣ d∩ NO╘ movσ thσ alia≤ int∩ thσ MCL.
  133.  
  134. No≈ át∩ thσ subjec⌠ oµ recursivσ aliases«  Recursioε occur≤ áwheε ì
  135. aε áalia≤ ácall≤ áitself« á Thi≤ migh⌠ ábσ áusefu∞ áiε áaε áEDIT¼ ì
  136. ASSEMBLE¼ LIN╦ sessioε wherσ aε erro≥ flaggeΣ b∙ thσ assemble≥ o≥ ì
  137. linke≥ áwoulΣ áautomaticall∙ pu⌠ yo⌡ bacδ iε you≥ edito≥ át∩ átr∙ ì
  138. agaiε áanΣ áthσ absencσ oµ error≤ woulΣ linδ anΣ áexit« á ╔ áwil∞ ì
  139. leavσ thσ usσ oµ 'recursionº t∩ thσ reade≥ anΣ concentratσ oε ho≈ ì
  140. t∩ writσ aliae≤ whicΦ arσ properl∙ recursive.
  141.  
  142. A⌠ áfirs⌠ áblush¼ i⌠ woulΣ seeφ tha⌠ wσ coulΣ d∩ ásomethinτ álikσ ì
  143. this..
  144.  
  145. FOO║ PROGRA═        Somσ prograφ whicΦ set≤ thσ Erro≥ flag
  146.      I╞ E╥          No≈ checδ fo≥ Error
  147.      FO╧            Re-ruε FO╧ oε error
  148.      F╔             Closσ thσ IF
  149.  
  150. AnΣ áwσ can¼ almost«  Iµ therσ i≤ aε error¼ FO╧ i≤ árerun« á Thi≤ ì
  151. leave≤ aε unresolveΣ I╞ oε thσ Flo≈ stacδ anΣ append≤ thσ las⌠ F╔ ì
  152. t∩ thσ 'newº alia≤ iε thσ MCL«  EacΦ iteratioε pushe≤ anothe≥ áI╞ ì
  153. ont∩ áthσ Flo≈ stacδ anΣ add≤ anothe≥ F╔ t∩ thσ MCL« á Everythinτ ì
  154. i≤ finσ unti∞ eithe≥ thσ Flo≈ stacδ overflow≤ (eigh⌠ IF'≤ max⌐ o≥ ì
  155. thσ áMC╠ fill≤ u≡ witΦ al∞ thσ FI's«  No⌠ reall∙ coo∞ becausσ áwσ ì
  156. neve≥ kno≈ ho≈ man∙ time≤ wσ reruε FO╧ no≥ ho≈ mucΦ rooφ wσ áhavσ ì
  157. iε thσ MCL«  
  158.  
  159. Thσ ásolutioε ái≤ ásimplσ ábu⌠ árequire≤ áß álittlσ áexplanation«  ì
  160. Rewritσ áthσ alia≤ s∩ tha⌠ it≤ 'recursionº neithe≥ overflow≤ áthσ ì
  161. Flo≈ stacδ no≥ thσ MCL«  Consider..
  162.  
  163. FOO║ F╔        Closσ I╞ ER
  164.      PROGRAM
  165. è     I╞ ER
  166.      FO╧       Reruε thi≤ alias
  167.  
  168. Thi≤ onσ ha≤ n∩ pendinτ F╔ t∩ overflo≈ thσ MC╠ anΣ wil∞ kee≡ áthσ ì
  169. Flo≈ ástacδ ástraigh⌠ whilσ i⌠ i≤ 'recurring'«  Thσ firs⌠ áF╔ ái≤ ì
  170. balanceΣ b∙ callinτ i⌠ correctl∙ witΦ anothe≥ alias¼ likσ this..
  171.  
  172. RUN║ I╞ ╘      Impres≤ Truσ oε thσ Flo≈ stack
  173.      FO╧       Executσ FOO
  174.      F╔        Closσ thσ IF
  175.  
  176. WatcΦ ho≈ nicel∙ thi≤ expands..
  177.  
  178. RUN║ I╞ ╘      Se⌠ Flo≈ True
  179. FOO║ F╔        Closσ I╞ ╘ froφ RU╬ o≥ I╞ E╥ froφ FOO
  180.      PROGRA═   Clear≤ (anΣ maybσ sets⌐ Erro≥ flag
  181.      I╞ ER
  182.      FO╧       Ruε FO╧ agaiε iµ ER
  183.      F╔        Froφ RUN¼ Closσ I╞ E╥ froφ FO╧ wheε n∩ Error
  184.  
  185. Perfectl∙ ábalanced«  Writteε thi≤ way¼ recursivσ aliase≤ d∩ áno⌠ ì
  186. corrup⌠ eithe≥ thσ Flo≈ stacδ o≥ thσ MCL«  Yo⌡ caε ente≥ command≤ ì
  187. followinτ áRU╬ oε thσ commanΣ linσ anΣ the∙ wil∞ áremaiε ápendinτ ì
  188. unti∞ RU╬ i≤ finisheΣ anΣ theε bσ executeΣ automatically.
  189.  
  190. Therσ ái≤ án∩ apparen⌠ neeΣ fo≥ ß 'Recursivσ áModeº áalia≤ áwhicΦ ì
  191. clear≤ ápendinτ command≤ froφ thσ MC╠ a≤ i⌠ runs«  'Norma∞ áModeº ì
  192. work≤ quitσ nicely¼ thanδ you«  
  193.  
  194. RoΓ FriefelΣ ha≤ appriseΣ mσ oµ aε articlσ iε TC╩ 2╕ b∙ Ja∙ áSagσ ì
  195. whicΦ present≤ thσ samσ argumen⌠ oε recursioε a≤ above«  ╔ swear¼ ì
  196. ╔ ádidn'⌠ áreaΣ tha⌠ article«  Maybσ 'grea⌠ ámindsº áthinδ áalikσ ì
  197. afte≥ all«  Perhap≤ ╔ caε offe≥ 'nestingº oµ aliases..
  198.  
  199. RUN:
  200.      I╞ ╘           PusΦ Truσ ont∩ thσ Flo≈ stack
  201.      MAI╬           Ruε MAIN
  202.      F╔             Po≡ thσ Flo≈ stacδ anΣ resumσ MC╠ commands
  203.  
  204. MAIN:
  205.      F╔             Po≡ thσ Flo≈ stack
  206.      PROG▒          D∩ something«  Se⌠ E╥ iµ wσ neeΣ FOO.
  207.      I╞ ER
  208.      FO╧            Ruε FO╧ iµ an∙ error
  209.      FI
  210.      I╞ E╥          FO╧ return≤ E╥ t∩ forcσ onσ morσ PROG1
  211. è     MAIN
  212.  
  213. FOO:
  214.      FI
  215.      PROG▓          D∩ something«  Clea≥ E╥ t∩ d∩ PROG▓ again.
  216.      I╞ ~E╥         Checδ thσ E╥ flag
  217.      FO╧            Reruε PROG2
  218.  
  219. Iε áthi≤ scenario¼ PROG▒ wil∞ bσ ruε anΣ oε error¼ PROG▓ i≤ árun«  ì
  220. Iµ áPROG▓ i≤ run¼ i⌠ wil∞ repea⌠ unti∞ i⌠ set≤ E╥ anΣ theε áPROG▒ ì
  221. wil∞ ábσ ruε again«  Thi≤ keep≤ u≡ unti∞ PROG▒ doe≤ no⌠ áse⌠ áthσ ì
  222. erro≥ flag.
  223.  
  224. ╔ áwil∞ áleavσ i⌠ t∩ thσ reade≥ discerε ß usσ fo≥ this¼ ábu⌠ áthσ ì
  225. forφ oµ thσ aliase≤ i≤ correc⌠ anΣ allow≤ yo⌡ t∩ appenΣ ácommand≤ ì
  226. t∩ RU╬ t∩ thσ exten⌠ oµ thσ MC╠ lengtΦ«  I⌠ expand≤ likσ this..
  227.  
  228. RUN:
  229.      I╞ ╘           PusΦ Truσ ont∩ thσ Flo≈ stack
  230. MAIN:
  231.      F╔             Po≡ thσ Flo≈ stack
  232.      PROG▒          D∩ something«  Se⌠ E╥ iµ wσ neeΣ FOO.
  233.      I╞ E╥          Ruε FO╧ iµ an∙ error
  234. FOO:
  235.      FI
  236.      PROG▓          D∩ something«  Clea≥ E╥ t∩ d∩ PROG▓ again.
  237.      I╞ ~E╥         Checδ thσ E╥ flag
  238.      FO╧            Reruε FO╧ iµ n∩ error
  239.  
  240.      FI
  241.      I╞ E╥          FO╧ return≤ E╥ t∩ forcσ onσ morσ PROG1
  242.      MAI╬           Ruε MAIN
  243.  
  244.      F╔             Po≡ thσ Flo≈ stacδ anΣ resumσ MC╠ commands
  245.  
  246.  
  247.