home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / zsus / tcj / tcj33upd.ws < prev    next >
Encoding:
Text File  |  1994-09-02  |  50.3 KB  |  1,022 lines

  1. This text is a version of my column in TCJ issue 33 which has been edited toì
  2. reflect the changes in ARUNZ from version 0.9J to 0.9N.  Not all newì
  3. features are reflected, but the example alias scripts should now work.
  4.       JPS 11/13/88
  5.  
  6.                                Z-System Corne≥ (c)
  7.                                  by Jay Sage
  8.                         The Computer Journal, Issue 33
  9.                           Reproduced with permission
  10.                            of author and publisher
  11.  
  12.  
  13.      For my column this time I plan to cover two subjects, both of which Iì
  14. have dealt with somewhat at length in the past.  Nevertheless, there justì
  15. seems to be a lot more to say on these subjects.  The first is ARUNZ; theì
  16. second is shells in general, and the way WordStar 4 behaves (or ratherì
  17. misbehaves) in particular.
  18.  
  19.      I was quite surprised and pleased by the enthusiastic response to myì
  20. detailed treatment of ARUNZ in issue 31.  Apparently, there were many, manyì
  21. people who were unaware of what ARUNZ was and who are now quite eager to putì
  22. it to use.  There are two specific reasons for taking up the subject ofì
  23. ARUNZ here again so soon.
  24.  
  25.      First of all, I think that readers will benefit from a discussion ofì
  26. some additional concrete examples.  Since my own uses are the ones I knowì
  27. best, I plan to take the ALIAS.CMD file from my own system as an example andì
  28. discuss a number of interesting scripts.  My first cut at doing that forì
  29. this column came out much too long, so I will cover half of the file thisì
  30. time.  The other half will be covered in the next column.
  31.  
  32.      The second reason is that I have just gone through a major upgrade toì
  33. ARUNZ.  It is now at version 0.9J.  Several aspects of its operation asì
  34. described in my previous column have been changed, and quite a few newì
  35. parameters have been added.
  36.  
  37.      The changes in ARUNZ were stimulated by two factors.  One is the twoì
  38. new dynamic Z Systems that will have been released by the time you readì
  39. this: NZCOM for Z80 computers running CP/M 2.2 and Z3PLUS for Z80 computersì
  40. running CP/M-Plus.  These two products represent a tremendous advance in theì
  41. concept of an operating system, and everyone interested in experimentingì
  42. with or using Z System -- even if he already has a manually installed ZCPR3ì
  43. running now -- should get the one that is appropriate to his computer.
  44.  
  45.      With these new Z System implementations, if your level of computerì
  46. skill is high enough to run a wordprocessor or menu program, then you canì
  47. have a Z System designed to your specifications in a matter of minutes.  Youì
  48. can change the design of your Z System at any time, even betweenì
  49. applications.  As described later, ARUNZ now has some parameters to returnì
  50. addresses of system components so that aliases can work properly even whenì
  51. those system components move around, as they may do under these dynamicì
  52. systems.
  53. è
  54.  
  55. My New Computer System
  56.  
  57.      The second impetus came from my finally building for myself a state-of¡
  58. the-art computer!  For most of my work in the past I have used a BigBoard Iì
  59. with four 8" floppy disk drives and an SB180 with four 5" disk drives. ì
  60. Neither machine had a hard disk.
  61.  
  62.      The SB180, my main system for the past year and a half, had beenì
  63. sitting on the floor in the study.  The pc board was mounted in a makeshiftì
  64. chassis with two power supplies, just as I got it from someone who bought itì
  65. at the Software Arts liquidation auction and after they had stripped out theì
  66. disk drives (at $25 I could hardly complain!).  I added my own drives, whichì
  67. sat in the open air (for cooling among other reasons) in two separate driveì
  68. cabinets elsewhere on the floor.  All in all not very pretty and not asì
  69. functional as it could have been.
  70.  
  71.      The sad part of it is that during all this time I had everything neededì
  72. to turn the SB180 into an enjoyable and productive system.  A high-speed 35ì
  73. Mb hard disk was collecting dust on a shelf; an attractive surplus Televideoì
  74. PC-clone chassis adorned the work bench in the basement; the XBIOS softwareì
  75. disks sat ignored in one of my many diskette boxes.
  76.  
  77.      Finally one weekend I decided that it would be more efficient in theì
  78. long run to take some time off from my programming and writing work toì
  79. reconstruct the system.  Indeed, it has been!  The SB180 is now attractivelyì
  80. mounted in the Televideo chassis with one 96-tpi floppy and one 48-tpiì
  81. floppy.  The hard disk is configured as four 8 Mb partitions and runs veryì
  82. nicely with the fast Adaptec 4000 controller.
  83.  
  84.      With the hardware upgraded, I then did the same to the software. ì
  85. Installing XBIOS on the SB180 took so little time that I really had to kickì
  86. myself for not doing it sooner.  Richard Jacobson was quite right in hisì
  87. description of it in issue 31.  Thank you, Malcom Kemp, for a really niceì
  88. product.
  89.  
  90.      Once I was fixing things up, I decided I should really do it up right,ì
  91. so I also purchased the ETS180IO+ board from Ken Taschner of Electronicì
  92. Technical Services -- this despite the fact that a Micromint COMM180 boardì
  93. was also a part of my longstanding inventory of unused equipment.  I cannotì
  94. compare the ETS board to the COMM180, never having used the latter, but Iì
  95. certainly am highly pleased with it.  XBIOS includes complete support forì
  96. the ETS board, so configuring the system to make use of the extra ETS180IO+ì
  97. features, like the additional parallel and serial ports and the battery¡
  98. backed clock, was very easy.
  99.  
  100.      I have been so pleased with the new system that I even went out andì
  101. bought a real computer table for it to sit on.  For the past years, theì
  102. terminal's CRT unit had been sitting on one of those flimsy folding dining¡
  103. room utility tables, with a yellow-pages phone book under it to jack it upì
  104. to the right height.  The keyboard sat on a second folding table, and theìèwhole thing was always in imminent danger of toppling over.  What a pleasureì
  105. it is to sit at the new system.
  106.  
  107.      While I'm waxing enthusiastic, let me mention one other thing I did toì
  108. reduce the disarray in the study.  I bought four Wilson-Jones media drawersì
  109. to house my vast collection of floppies.  These diskette cabinets resembleì
  110. professional letter filing cabinets.  A drawer, which can hold more than 100ì
  111. floppies, pulls out on a full suspension track so that one can easily reachì
  112. all the way to the back.  Since there is no top to flip open, units can beì
  113. stacked on top of each other to save a great deal of table space.  Clips areì
  114. provided to secure the units to their neighbors both horizontally andì
  115. vertically.
  116.  
  117.      The only drawback to these disk drawers has been their cost.  Inmac andì
  118. the other major commercial supply houses want more than $60 each!  Butì
  119. Lyben, which sends its catalogs out to many computer hobbyists, offers themì
  120. for only $35.  Extra dividers, which I recommend, are just under $6 perì
  121. package of five.  Lyben can be reached at 313-589-3440 (Michigan).  [Noteì
  122. added at last moment -- I am sorry to say that I just received the new Lybenì
  123. catalog, and the price has now gone up to $45.  Although this is still aì
  124. bargain when compared to other vendors' prices, I'm glad I put in my orderì
  125. when I did.]
  126.  
  127.  
  128.                              ARUNZ VERSION 0.9J
  129.                          (edited for version 0.9n)
  130.  
  131.      Now that I have had my chance to show my excitement over the new stateì
  132. of my computer and computer room, let's get on with the discussion of ARUNZ. ì
  133. First we will discuss the changes introduced since version 0.9G, both theì
  134. old features that have changed and the new features that have beenì
  135. introduced.
  136.  
  137.  
  138. Changes in Old Features
  139. -----------------------
  140.  
  141.      Because, as noted in my last column, ZCPR34 can pass commandsì
  142. containing explicit file types or wildcard characters ('?' and '*'), theì
  143. characters used to define special matching conditions in the alias names inì
  144. ALIAS.CMD had to be changed.  The period, which had been used to indicateì
  145. the beginning of optional characters in the alias name, has been replaced byì
  146. the comma.  The question mark had been used to indicate a wild-characterì
  147. match in the alias name.  Since it can now be an actual character to beì
  148. matched, the underscore has replaced it.
  149.  
  150.      Since the command verb can now include an explicit file type (notì
  151. necessarily COM) and/or a directory prefix, several changes have been madeì
  152. to the parameters that parse the command verb.  In general, all of theì
  153. command line tokens are now treated in the same way; all four token parsingì
  154. parameters ('D', 'U', ':', and '.') now work with digits from 0 to 9 and notì
  155. just 1 to 9.  Thus the command line
  156. è
  157.     C3:TEST>arunz b12:test.z80 commandtail
  158.  
  159. or, with ARUNZ running as the extended command processor (ECP), the command
  160.  
  161.     C3:TEST>b12:test.z80 commandtail
  162.  
  163. will have the following parameter values for token 0, the command verb:
  164.  
  165.     $TD0    B    (Token 0 Drive)
  166.     $TU0    12    (Token 0 User)
  167.     $TN0    TEST    (Token 0 fileName)
  168.     $TT0    Z80    (Token 0 fileType)
  169.  
  170. THIS IS A SIGNIFICANT CHANGE.  PLEASE TAKE CAREFUL NOTE OF IT.  Theì
  171. parameters $TD0 and $TU0 no longer necessarily return the logged-in driveì
  172. and user.  For the standard configuration of ZCPR33 (and 34) a verb of theì
  173. form B12:TEST cannot be passed to the extended command processor; theì
  174. presence of an explicit directory specification results in the immediateì
  175. invocation of the error handler (skipping the ECP) if the file cannot beì
  176. found in the specified directory.  However, if a file type is included, theì
  177. 'bad' command will be passed to the ECP.
  178.  
  179.  
  180. New Features
  181.  
  182.      There are now three new parameters that do return information about theì
  183. directory that was current (logged in) when ARUNZ was invoked.  Theseì
  184. parameters are shown below with their meaning and the values they would haveì
  185. with the example command above:
  186.  
  187.       parameter              meaning            value
  188.       ---------             -------            -----
  189.     $HD        Home Drive (D)              C
  190.     $HU        Home User (U)              3
  191.     $HB        Home Both (i.e., DU)          C3
  192.  
  193.      There is also a new parameter to denote the entire command line,ì
  194. including both the command verb and the command tail.  Many people in theì
  195. past confused "command line" with "command tail" and attempted to use theì
  196. parameter $* for the former.  The new parameter is '$!'.  It is roughlyì
  197. equivalent to '$0 $*', but there is one important difference.  The latterì
  198. parameter expression always includes a space after the command verb, even ifì
  199. there was no tail ('$*' was null).  This space caused problems with someì
  200. commands.  For example, when the SLR assembler SLR180 is invoked withì
  201. nothing after it, it enters interactive mode and allows the user to enter aì
  202. series of assembly requests.  Unfortunately, the code is not smart enough toì
  203. distinguish a completely nonexistent command tail from one with only spaces. ì
  204. When the command "SLR180_" is entered, where '_' represents a blank space,ì
  205. the assembler looks for a source file with a null name.  Not finding it, itì
  206. returns with an error message.
  207.  
  208. è     I used to deal with this problem by writing a complex alias of theì
  209. form:
  210.  
  211.     SLR180    if nu $*;asm:slr180;else;asm:slr180 $*;fi
  212.  
  213. With the new parameter, all this complication can be avoided.  The script isì
  214. simply:
  215.  
  216.     SLR180    asm:$!
  217.  
  218. If you are wondering why one would want an alias like this, just wait aì
  219. while.  It will be explained later.
  220.  
  221.      There is also a whole set of new parameters that generate the addressesì
  222. of almost all of the Z System modules.  This capability will becomeì
  223. important with the dynamic Z Systems now being introduced (NZCOM andì
  224. Z3PLUS).  With those systems, the addresses of the RCP, FCP, CCP, and so onì
  225. can all change during system operation.  The new parameters permit one toì
  226. make reference to the addresses of those modules even when they move around. ì
  227. My ALIAS.CMD file described below will have some examples of how theseì
  228. parameters are used.
  229.  
  230.      These parameters begin with $A ('A' for address) and are followed by anì
  231. additional letter as follows:
  232.  
  233.     B    BIOS            L    MCL (command Line)
  234.     C    CCP            M    MSG (message buffer)
  235.     D    DOS            N    NDR
  236.     E    ENV            P    PATH
  237.     F    FCP            R    RCP
  238.     I    IOP            S    STK (shell stack)
  239.                     X    XFCB (external FCB)
  240.  
  241. Amazingly enough, these names are all mnemonic except for the conflict overì
  242. 'M' between the multiple command line buffer (MCL) and message buffer (MSG). ì
  243. I resolved this by using 'L' (think of LINE) for the MCL.
  244.  
  245.      Finally, there is a new symbol that can be used to make a special kindì
  246. of alias name specification in ALIAS.CMD.  If a name element begins with aì
  247. '>', then only the file type of the command verb is used in the comparison. ì
  248. Without this feature one had to use very complex forms to recognize a fileì
  249. type.  For example, suppose you want to be able to enter the name of aì
  250. library file as LBRNAME.LBR as a command and have VLU invoked on it.  Theì
  251. following script used to be required:
  252.  
  253.     ?.LBR=??.LBR=???.LBR=????.LBR=?????.LBR=??????.LBR=
  254.       ???????.LBR=????????.LBR   vlu $0
  255.  
  256. Every possible number of characters in the library name had to be dealt withì
  257. explicitly.  With the new symbol and the other ARUNZ09J features, one canì
  258. define this script more simply as follows:
  259.  
  260. è    >LBR    vlu $TN0
  261.  
  262.  
  263. Example ALIAS.CMD File
  264.  
  265.      Now that we have described the new resources available in ARUNZ09J, weì
  266. will begin our look at part of the ALIAS.CMD file that I am using right nowì
  267. on the SB180.  It will be the second half of the file, because that partì
  268. contains some items of immediate relevance.
  269.  
  270.      First some words of philosophy.  There are many ways in which Z Systemì
  271. can be used effectively, and I am always amazed and impressed at theì
  272. different styles developed by different users.  What I will now describe isì
  273. my approach.  As they say, yours may differ!  In any case, I hope theseì
  274. comments will stimulate some good ideas, and, as always, I eagerly awaitì
  275. your comments and suggestions.
  276.  
  277.      I am a strong believer in short search paths.  When I make a mistake inì
  278. typing a command, I do not want to have to twiddle my thumbs while theì
  279. command processor thrashes through a lot of directories searching for theì
  280. nonexistent command.  I want the error handler to take care of it as quicklyì
  281. as possible.  As a result, the search path on my SB180 includes only oneì
  282. directory, A0, the RAM disk.  (With XBIOS, the RAM disk can be mapped to theì
  283. A drive.)
  284.  
  285.      When I enter a command, it is searched for only in A0.  If it is notì
  286. found there, then ARUNZ (renamed to CMDRUN.COM) is loaded from A0, and itì
  287. looks for a script in ALIAS.CMD, also in A0.  If ARUNZ cannot resolve theì
  288. command, then the error handler, EASE in my case, is invoked (you guessedì
  289. it, also on A0).  Thus no directory other than the RAM disk is accessedì
  290. except by an explicit directory reference generated either by an aliasì
  291. script or by a manually entered command.  Everything appears to operateì
  292. instantaneously.
  293.  
  294.  
  295. Aliases to Provide Explicit Directory Prefixes
  296.  
  297.      Obviously, I cannot keep all the COM files that I use in directory A0. ì
  298. In fact, with the tiny RAM disk on the SB180 (and allowing about 100K for aì
  299. BGii swap file), there is barely enough room for CMDRUN.COM (ARUNZ),ì
  300. ALIAS.CMD, EASE.COM, EASE.VAR, IF.COM, ZF.COM (ZFILER), ZFILER.CMD,ì
  301. SAVSTAMP.COM, ZEX.COM, ZEX.RSX, and a few directory programs.  Fortunately,ì
  302. this is all that really needs to be there.
  303.  
  304.      So what do I do about all the other COM files that I want to use? ì
  305. There are two possibilities.  I could invoke them manually with explicitì
  306. directory references, as in "B0:CRC FILESPEC", but this would clearly be aì
  307. nuisance (and contrary to the spirit of Z System!).  The other alternativeì
  308. is to provide alias definitions in ALIAS.CMD for all the commands in otherì
  309. directories that I want to use.
  310.  
  311.      A second half of my ALIAS.CMD file is shown in Listing 1.  The group ofìèaliases at the very end comprises several sets of definitions that do justì
  312. what I have described for several of the directories on the hard disk.  As Iì
  313. use programs in other directories, I add them to the ALIAS.CMD file.
  314.  
  315.      These aliases are included at the end, by the way, so that otherì
  316. definitions can preempt them as desired.  If you look carefully, you willì
  317. see some aliases defined here that are also defined earlier in the ALIAS.CMDì
  318. file.  The earliest definition always takes precedence, because ARUNZ scansì
  319. ALIAS.CMD from the beginning and stops as soon as it encounters a matchingì
  320. name specification.
  321.  
  322.      Directory B0, named SYS, contains most of my system utilities. ì
  323. Directory B1, named ASM, contains my assembly language utilities.  A fewì
  324. commonly used files are in other directories.  The aliases defined in theseì
  325. sections do nothing more than add an explicit directory prefix to theì
  326. command entered.  For example, the script definition
  327.  
  328.     AFIND    b0:$!
  329.  
  330. would take my command line "AFIND TAIL..." and turn it into "B0:AFINDì
  331. TAIL...".  Note how compact the definitions can be.  You do not need aì
  332. separate line for each command.  Similar scripts could be constructed, byì
  333. the way, for COM files kept in COMMAND.LBR and extracted and executed by LX. ì
  334. I do not use LX, so I have no examples to show.
  335.  
  336.      There are several fairly easy ways to automate the construction ofì
  337. these entries in the ALIAS.CMD file.  If you use PMATE or VEDIT as your textì
  338. editor, you can write macros that will perform the entire process.  That isì
  339. how I generated the aliases you see.  With the PMATE macro, I can easilyì
  340. repeat the process from time to time to make sure that all my COM files areì
  341. represented by aliases.    So far I have run my PMATE macro on user areas 0,ì
  342. 1, 2, 3, and 4 of hard disk partition B.
  343.  
  344.      Lacking these tools, you can run "SD *.COM /FX" to get a file DISK.DIRì
  345. containing a horizontally sorted listing of all the COM files in a directoryì
  346. (without going to a lot of trouble, I do not get a sorted listing fromì
  347. PMATE).  Then use your favorite editor, whatever it is, to add carriageì
  348. returns so that each file is on its own line and to delete all of the textì
  349. after the file name (i.e., the dot, file type, and file size).  If there areì
  350. any commands for which you want to have special aliases (we'll see someì
  351. examples shortly), you may delete their names from the list (or you canì
  352. leave them -- they do no harm).  Then close up the list, inserting equalì
  353. signs and, when the line is wide enough, add the command script.  Finally,ì
  354. merge this with the rest of your ALIAS.CMD file.
  355.  
  356.  
  357. Aliases for Special Command Redefinitions
  358.  
  359.      Just before the simple redefinition aliases there are six commands thatì
  360. have been separated out for special treatment.  Consider the first of them:
  361.  
  362.     ZP,ATCH        b0:zpatch $*
  363. è
  364. I find that my fingers have some difficulty typing the full ZPATCHì
  365. correctly, and this alias permits me to enter simply ZP.  Note that in thisì
  366. case we cannot use "b0:$!" for the script because the alias name allows forì
  367. forms other than an exact ZPATCH.  If the script used the $! parameter andì
  368. the command was entered as ZP, then the expanded script would become "B0:ZPì
  369. ...", which would not work.
  370.  
  371.      The alias for crunching is similar in some respects but more elaborate. ì
  372. The letter combination CH must give me trouble, because I often type CRUNCHì
  373. wrong, too, unless I work very carefully.  This alias not only lets me useì
  374. the short form CR; it also allows the command to work with namedì
  375. directories.
  376.  
  377.     CR,UNCH         b0:crunch $td1$tu1:$tf1 $td2$tu2:
  378.  
  379. By expanding the first and second parameters explicitly, named directoryì
  380. references can be converted to the DU: form that CRUNCH can deal with.
  381.  
  382.      The alias for DATSWEEP goes a little further than the other two insofarì
  383. as alternative forms are concerned.
  384.  
  385.     DATSW,EEP=DS=SWEEP    b0:datsweep $*
  386.  
  387. It allows abbreviated forms as short as DATSW, but it additionally allowsì
  388. alternative nicknames for the command, such as DS or the more familiarì
  389. SWEEP, which it replaces on my system.
  390.  
  391.      The next example in this section shows how a program that does not knowì
  392. about Z System file specifications at all can be made to work with themì
  393. anyway.
  394.  
  395.     LDIR        $td1$tu1:;b0:ldir $tn1;$hb:
  396.  
  397. For LDIR I just started to use LDIR-B, which displays date stamp informationì
  398. about files in the library.  Unfortunately, it does not know about namedì
  399. directories; in fact, it does not even know anything about user numbers.  Ifì
  400. he is true to form, Bruce Morgen, the Intrepid Patcher, will soon have aì
  401. ZLDIR-B or an LDRZ-B that will accept full Z System file specs, and I willì
  402. be able to retire this alias.
  403.  
  404.      At present, however, LDIR-B accepts only the standard CP/M syntax forì
  405. files.  As a result, it is not enough simply to pick apart the token, as itì
  406. would be if LDIR would accept the form DU:NAME.TYP.  Instead, the directoryì
  407. specified for the library is logged into, then the LDIR command is run onì
  408. the library name, and finally the original directory is relogged.  This willì
  409. work very nicely unless the user number specified is higher than 15 (andì
  410. your Z33/Z34 is not configured for logging into high user numbers).
  411.  
  412.      The last two examples in this series illustrate still another way toì
  413. make aliases lighten the typing burden.  With XBIOS, alternative versions ofì
  414. the operating system are described in model files.  These typically have aì
  415. file type of MDL, but that type is not required or the default. ìèConsequently, the SYSBLD system-defining utility and the XBOOT system¡
  416. loading utility must be given an explicit file type.  Since I always use MDLì
  417. for the type, I created these aliases to add the file type for me so that Iì
  418. can enter the commands simply as "SYSBLD TEST" or "XBOOT BIGSYS".
  419.  
  420.     SYSBLD            b0:;b0:$0 $1.mdl;$hb:
  421.     BOOT=XBOOT        b0:;b0:xboot $1.mdl
  422.  
  423. The XBOOT alias lets me save a little typing by omitting the leading 'X' ifì
  424. I wish.  The SYSBLD alias returns to the original directory when it isì
  425. finished.  Since XBOOT coldboots a new operating system, any trailingì
  426. commands are lost anyway.  The XBOOT command will soon support a warmbootì
  427. mode, in which, like NZCOM and Z3PLUS, the new system is created withoutì
  428. affecting the multiple command line, shell stack, or other loaded systemì
  429. modules that have not changed their address or size.  I might then add anì
  430. alias REBOOT or WBOOT (warmboot) that will load a new system and return toì
  431. the original directory.
  432.  
  433.  
  434. Memory Display Aliases
  435.  
  436.      In my system development work I often have occasion to examine variousì
  437. parts of memory.  I might want to look at the beginning of the BIOS to checkì
  438. the hooks into an RSX (resident system extension), or I might want to seeì
  439. the contents of the ZCPR3 message buffer to see how some flags are beingì
  440. used.
  441.  
  442.      I used to have a set of aliases like these with explicit addresses inì
  443. the script ("P FE00" to look at the ENV, for example).  This relieved myì
  444. mind of the task of remembering the addresses where these modules wereì
  445. located in memory.  With the new dynamic systems, even a good memory willì
  446. not suffice, since the modules can move around, and one can not easily beì
  447. sure just where they are at any given time.
  448.  
  449.      By using the new parameters that I described earlier, the scriptsì
  450. always have the correct addresses.  [Actually, they can still be fooled ifì
  451. these parameters are used in multiple-command-line scripts that include theì
  452. loading of a new dynamic system.  As I warned in my earlier article onì
  453. ARUNZ, all parameters are expanded at the time the alias is invoked.  If theì
  454. system is changed after that, the parameter values may no longer be correctì
  455. when that part of the script actually runs.]
  456.  
  457.  
  458. =============================================================================
  459.  
  460.  
  461.  ; Memory display aliases
  462.  
  463. PBIOS=BIOS        p $ab
  464. PCCP=CCP=CPR        p $ac
  465. PDOS=DOS        p $ad
  466. PENV=ENV        p $ae
  467. èPFCP=FCP        p $af
  468. PIOP=IOP        p $ai
  469. PMCL=MCL        p $al
  470. PMSG=MSG        p $am
  471. PNDR=NDR        p $an
  472. PPATH            p $ap
  473. PRCP=RCP        p $ar
  474. PSHL=PSHELL=SHL=SHELL    p $as
  475. PXFCB=XFCB=PFCB=FCB    p $ax
  476.  
  477.  ; Special equivalents
  478.  
  479. ZP,ATCH            b0:zpatch $*
  480. CR,UNCH             b0:crunch $td1$tu1:$tf1 $td2$tu2:
  481. DATSW,EEP=DS=SWEEP    b0:datsweep $*
  482. LDIR            $td1$tu1:;b0:ldir $tn1;$hb:
  483. SYSBLD            b0:;b0:$0 $1.mdl;$hb:
  484. XBOOT=BOOT        b0:;b0:xboot $1.mdl
  485.  
  486.  ; Complete set of direct equivalents
  487.  
  488. CMDRUN=LPUT=EDIT0=ERA=IF=REN=SD=SDD=XD=ZEX=ZF=VLU=W=ZPATCH=COPY=ECHO    b0:$!
  489. FF=GOTO=JF=JETLDR87=NULU=PWD=SAVE=SP=UNCR=VTYPE=XDIR=AFIND=SALIAS=AREA    b0:$!
  490. BD=CRUNCH=DFA=DIFF=DISKRST=DOSERR=DU=EDITNDR=ERRSET=HSH=ALIAS        b0:$!
  491. LLF=LGET=LOADNDR=LPUT14=LT23=LUSH=LX=MOVE=MU3=PATH=PAUSE=PIP=PROT    b0:$!
  492. PROTCCP=PUBLIC=PUTDS=Q=SAP=SAVENDR=SAVSTAMP=SFA=SHCTRL=SHOW=SQ=STAT    b0:$!
  493. SUB=SYSGEN=UF=UNERASE=XSUB=DATE=DATSWEEP=MKDIR=SHSET=TPA=Z3INS=Z3LOC    b0:$!
  494. ZRIP=ASSGN=BSX=FVCD=HDINIT=HDUTIL=MDINIT=MPTEST=SETDFLT=STARTHD4=SWX    b0:$!
  495. SYSBLD=XSYSGEN=TIME=XBOOT0=XVERS=MCOPY=LZED=PUTBG=STARTHD=STARTHD1    b0:$!
  496. STRTFULL=LDR=JETLDR=LHC=SSTAT=XBOOT=MAP=STARTBIG=LT=LDIR=QL=SETD=CRC    b0:$!
  497. 4ERA=4MU3=4REN=4SAVE=T4MAKE=DOSVER=DRO=LOGGED=SRO=SRW=LBREXT        b0:$!
  498.  
  499. SLR180+=SLRNK=SLRNK+=Z80ASM=DDT=DSDZ=FORM7=MAKESYM=MLOAD=SLRMAC=XIZ    b1:$!
  500. ZAS=ZLINK=ZXLATE=SLR180=180FIG32=180FIG+=LNKFIG+=SLRIB=ZLIB=ZREF    b1:$!
  501. ZZCNFG=LNKFIG=180FIG                            b1:$!
  502.  
  503. BGSERIAL=LOADBG=STARTBG=BGPRINT=BGPRNCFG=DSCONFIG=Q=REMOVE=SECURE    b2:$!
  504. SETBG=SPOOLER=DATSWEEP=SDD=SETTERM                    b2:$!
  505.  
  506. INSTALL=MEX                                b3:$!
  507.  
  508. WSCHANGE=WS=WINSTALL=MOVEPRN                        b4:$!
  509. Listing 1.  The second half of the ALIAS.CMD file from my SB180 with XBIOS,ì
  510. slightly shortened and rearranged.
  511.  
  512. =============================================================================
  513.  
  514.                        Shells and WordStar Release 4
  515.  
  516.  
  517.      As I noted in an earlier column, WordStar Release 4 was a very excitingì
  518. event for the CP/M world in general and the Z-System world in particular. ìèIt was the first major commercial program to recognize Z System and to makeì
  519. use of its features.  Unfortunately, the Z System code in WS4 was notì
  520. adequately tested, and many errors, some quite serious, slipped through. ì
  521. Some of the most significant errors concern WS4's operation as a ZCPR3ì
  522. shell.
  523.  
  524.      Let's begin with a little background on the concept of a shell in ZCPR. ì
  525. Normally, during Z System operation the user is prompted for command lineì
  526. input.  This input may consist of a string of commands separated byì
  527. semicolons.  When the entire sequence of commands has been completed and theì
  528. command line buffer is again empty, the user would be prompted again forì
  529. input.
  530.  
  531.      This prompting is performed by the ZCPR command processor, which,ì
  532. because it is limited in size to 2K, is correspondingly limited in itsì
  533. power.  Richard Conn, creator of ZCPR, had the brilliant idea of including aì
  534. facility in ZCPR3 for, in effect, replacing -- or, perhaps better said,ì
  535. augmenting -- the command processor as a source of commands for the system. ì
  536. This is the shell facility.
  537.  
  538.      Under ZCPR3, when the command processor finds that there are no moreì
  539. commands in the command line buffer for it to perform, before it prompts theì
  540. user for input, it first checks a memory buffer called the shell stack.  Ifì
  541. it finds a command line there, it executes that command immediately, withoutì
  542. prompting the user for input.  The program run in that way is called aì
  543. shell, because it is like a shell around the command processor kernel.  Theì
  544. shell is what the user sees instead of the command processor, and the shellì
  545. will normally get commands from the user and pass them to the commandì
  546. processor.  In effect, the outward appearance of the operating system can beì
  547. changed completely when a shell is selected.
  548.  
  549.      A perfect example of a shell is the EASE history shell.  To the user itì
  550. looks rather like the command processor.  But there are two very importantì
  551. differences.  First of all, the command line editing facilities are greatlyì
  552. augmented.  One can move the cursor left or right by characters, words, orì
  553. commands; one can insert new characters or enter new characters on top ofì
  554. existing characters; characters or words can be deleted.  One has, in a way,ì
  555. a wordprocessor at one's disposal in creating the command line.
  556.  
  557.      The second feature is the ability to record and recall commands in aì
  558. history file.  Many users find that they execute the same or similarì
  559. commands repeatedly.  The history feature of EASE makes this veryì
  560. convenient.  These two command generation features require far too much codeì
  561. to include in the command processor itself, so it is very convenient to haveì
  562. the shell capability.
  563.  
  564.      Programs designed to run as shells have to include special code toì
  565. distinguish when they have been invoked by the user and when they have beenì
  566. invoked by the command processor.  ZCPR3 makes this information available toì
  567. such programs.  When invoked by the user, they simply write the appropriateì
  568. command line into the shell stack so that the next time the commandì
  569. processor is ready for new input, the shell will be called on.  After that,ìèthe user sees only the shell.  Shells normally have a command that the userì
  570. can enter to turn the shell off.
  571.  
  572.      ZCPR3 goes beyond having just a single shell; it has a stack of shells. ì
  573. A typical configuration allows four shell commands in the stack.  When theì
  574. user invokes a command designed to run as a shell, it pushes its name ontoì
  575. the stack.  When the user cancels that shell, any shell that had beenì
  576. running previously comes back into force.  Only when the last shell commandì
  577. has been cancelled (popped from the shell stack) does the user see theì
  578. command processor again.
  579.  
  580.      Let's look at some of the shells that are available under Z System.  Weì
  581. have already mentioned the EASE history shell.  There is also the HSHì
  582. history shell, which offers similar capabilities.  It was written in C andì
  583. cannot be updated to take advantage of innovations like type-3 and type-4 commands.  I would say that EASE is the history shell of choice today.  Thisì
  584. is especially true because EASE can do double service as an error handler asì
  585. well, with the identical command line editing interface.
  586.  
  587.      Then there are the menu shells, programs that allow the user with justì
  588. a few keystrokes to initiate desired command sequences.  They come inì
  589. several flavors.  MENU stresses the on-screen menu of command choicesì
  590. associated with single keystrokes.  VFILER and ZFILER stress the on-screenì
  591. display of the files on which commands will operate; the commands associatedì
  592. with keys are not normally visible.  Z/VFILER offer many internal fileì
  593. maintenance commands (copy, erase, rename, move, archive).  VMENU andì
  594. FMANAGER are inbetween.  Both the files in the directory and the menu ofì
  595. possible commands are shown on the screen.
  596.  
  597.  
  598. What Kind of Programs Should be Shells?
  599.  
  600.      Not all programs should be shells.  From a strict conceptual viewpoint,ì
  601. only programs that are intended to take over the command input function fromì
  602. the command processor on a semipermanent basis should be shells.  Theì
  603. history shells and the MENU and VMENU type shells clearly qualify.  Oneì
  604. generally enters those environments for the long haul, not just for a quickì
  605. command or two.
  606.  
  607.      ZFILER and VFILER are marginal from this viewpoint.  One generallyì
  608. enters them to perform some short-term file maintenance operations, afterì
  609. which one exits to resume normal operations.  It is rare, I believe, toì
  610. reside inside ZFILER or VFILER for extended periods of time, though I amì
  611. sure there are some users who do so.
  612.  
  613.      Many people (I believe mistakenly) try to set up as shells any programì
  614. from which they would like to run other tasks and automatically return. ì
  615. This is the situation with WordStar.  No one will claim that the mainì
  616. function of WordStar is to generate command lines!  Clearly it is intendedì
  617. to be a file editor.  Why, then, was it made into a ZCPR3 shell in the firstì
  618. place?  I'm really not sure.
  619.  
  620.      WordStar's 'R' command really does not offer very much.  In neither theìèZCPR nor the CP/M configuration does any information about the operatingì
  621. environment seem to be retained.  For example, one might expect on return toì
  622. WordStar that the control-r function would be able to recall the mostì
  623. recently specified file name.  But this does not seem to be the case,ì
  624. although it could easily have been done.  In the ZCPR version, the nameì
  625. could be assigned to one of the four system file names in the environmentì
  626. descriptor; in the CP/M version it could be kept in the RSX code at the topì
  627. of the TPA that enables WordStar to be reinvoked after a command isì
  628. executed.
  629.  
  630.      The WordStar 'R' command does not save any time, either.  Essentiallyì
  631. no part of WordStar remains in memory.  The user could just as well use theì
  632. 'X' command to leave WordStar, run whatever other programs he wished, andì
  633. then reinvoke WS.  Nevertheless, I can understand why users would enjoy theì
  634. convenience of a command like the 'R' command that automatically brings oneì
  635. back to WordStar.  Shells, however, are not the way to do this, at least notì
  636. shells in the ZCPR3 sense.
  637.  
  638.  
  639. ZCPR2-Style Shells
  640.  
  641.      In ZCPR2 Richard Conn had already implemented an earlier version of theì
  642. shell concept which, interestingly enough, would be the appropriate way forì
  643. WordStar and perhaps even ZFILER/VFILER to operate.  He did not have a shellì
  644. stack, but he did have programs like MENU that, when they generatedì
  645. commands, always appended their own invocation to the end of the commandì
  646. line.  Thus if the menu command script associated with the 'W' key was "WSì
  647. fn2", where fn2 represents system file name #2, then the actual commandì
  648. placed into the command line buffer would be "WS fn2;MENU".  In this way,ì
  649. after the user's command ran, the MENU program would come back.
  650.  
  651.      Let's compare how the two shell schemes would have worked withì
  652. WordStar.  Suppose we want to edit the file MYTEXT.DOC and then copy it toì
  653. our archive disk with the command "PPIP ARCHIVE:=MYTEXT.DOC".  We might haveì
  654. created the following alias script for such operations:
  655.  
  656.     WSWORK    ws $1;ppip archive:=$1
  657.  
  658. Then we just enter the command "WSWORK MYTEXT.DOC" when we want to work on theì
  659. file and have it backed up automatically when we are done.
  660.  
  661.      Here is what WS4 does as a ZCPR3-type shell.  The command line starts outì
  662. as:
  663.  
  664.     WSWORK MYTEXT.DOC
  665.  
  666. When the alias WSWORK is expanded the command line becomes:
  667.  
  668.     WS MYTEXT.DOC;PPIP ARCHIVE:=MYTEXT.DOC
  669.  
  670. When WordStar runs, it pushes its name onto the shell stack so that it will beì
  671. invoked the next time the command line is empty.  Noting that the command lineìèis not empty, it returns control to the command processor.  Then the PPIPì
  672. command is executed, backing up our unmodified file (horrors!!!)  Finally theì
  673. command line is empty and WS, as the current shell, starts running.  Since itì
  674. was invoked as a shell, it prompts the user to press any key before it clearsì
  675. the screen to start editing.  By this time it has forgotten all about the fileì
  676. we designated and it presents us with the main menu.  All in all, a ratherì
  677. foolish and useless way to go about things.
  678.  
  679.      You might think that the problem would be solved if WS did not check forì
  680. pending commands but went ahead immediately with its work.  Indeed, this wouldì
  681. work fine until the 'R' command was used.  Then either the pending PPIP commandì
  682. would be lost (replaced by the command generated by the 'R' operation) orì
  683. executed (if the 'R' command appended it to the command it generated).  Inì
  684. either case we have disaster!
  685.  
  686.      Now suppose WS4 had used the ZCPR2-style shell concept.  After the aliasì
  687. had been expanded, the "WS MYTEXT.DOC" command would run, and we would edit ourì
  688. file.  While in WS4, suppose we want to find where on our disks we have filesì
  689. with names starting with OLDTEXT.  We use the 'R' command to enter the commandì
  690. line "FF OLDTEXT".  The 'R' command would append ";WS" to the end the commandì
  691. we entered and insert it into the command line buffer before the currentì
  692. pointer, leaving the following string in the buffer:
  693.  
  694.     FF OLDTEXT;WS;PPIP ARCHIVE:=MYTEXT.DOC
  695.  
  696. After the FF command was finished, WordStar would be executed again.  Just whatì
  697. we wanted.
  698.  
  699.      In fact, under ZCPR3 WS could be much cleverer than this.  First of all,ì
  700. it could determine from the external file control block the name (and under Z33ì
  701. the directory) used to invoke WordStar in the first place.  There would be noì
  702. need, as there is now, to configure WS to know its own name and to make sureì
  703. that the directory with WS is on the command search path.  The 'R' commandì
  704. could have appended "B4:WSNEW" if WSNEW had been its name and it had beenì
  705. loaded from directory B4.
  706.  
  707.      There is one problem, however.  We would really like WS to wait beforeì
  708. clearing the screen and obliterating the results of the FF command.  With theì
  709. ZCPR3-type shell, WS can determine from a flag in the ZCPR3 message bufferì
  710. whether it was invoked as a shell.  For the ZCPR2-style shell we would have toì
  711. include an option on the command line.  WS could, for example, recognize theì
  712. command form "WS /S" as a signal that WS was running as a shell.  It would thenì
  713. wait for a key to be pressed before resuming, just as under a ZCPR3-styleì
  714. shell.  Of course, you would not be able to specify an edit file with the nameì
  715. "/S" from the command line in this case, but that is not much of a sacrifice orì
  716. restriction.
  717.  
  718.      We could continue to work this way as long as we liked.  Only when weì
  719. finally exited WS with the 'X' command would the PPIP command run.  This, ofì
  720. course, is just the right way to operate!
  721.  
  722.  
  723. èZCPR2 vs ZCPR3 Shell Tradeoffs
  724.  
  725.      Once I started thinking about the old ZCPR2-type shells, I began to wonderì
  726. why one would ever want a ZCPR3-type shell.  At first I thought that Z2-styleì
  727. shells could not be nested, but that does not seem to be the case.  Suppose weì
  728. run MENU and select the 'V' option to run VFILER.  The command line at thatì
  729. point would be
  730.  
  731.     VFILER;MENU /S
  732.  
  733. where we have assumed that a "/S" option is used to indicate invocation as aì
  734. shell.  While in VFILER we might run a macro to crunch the file we are pointingì
  735. to.  The macro could spawn the command line "CRUNCH FN.FT".  The command lineì
  736. buffer would then contain
  737.  
  738.     CRUNCH FN.FT;VFILER /S;MENU /S
  739.  
  740. After the crunch is complete, VFILER would be reentered.  On exit from VFILERì
  741. with the 'X' command, MENU would start to run.  Thus nesting is not onlyì
  742. possible with Z2-type shelling, it is not limited by a fixed number of elementsì
  743. in the shell stack as in ZCPR3 (the standard limit is 4).  Only the size of theì
  744. command line buffer would set a limit.
  745.  
  746.      What disadvantages are there to the Z2-style shell?  Well, I'm afraid thatì
  747. I cannot come up with much in the way of substantial reasons.  The shell stackì
  748. provides a very convenient place to keep status information for a program.  Iì
  749. do that in ZFILER so that it can remember option settings made with the 'O'ì
  750. command.  On the other hand, this information could be kept as additional flagsì
  751. on the command line, as with the "/S" option flag.  There is no reason why theì
  752. information could not be stored even in binary format, except that the nullì
  753. byte (00 hex) would have to be avoided.
  754.  
  755.      If the 128 bytes currently set aside for the shell stack were added to theì
  756. multiple command line buffer, the use of memory would be more efficient than itì
  757. is now with Z3-style shells.  Z3 shells use shell stack memory in fixed blocks;ì
  758. with Z2 shells the space would be used only as needed.  I rarely have more thanì
  759. one shell running, which means that most of the time 96 bytes of shell stackì
  760. space are totally wasted.  Of course, with the present setup of ZCPR3, theì
  761. multiple command line buffer cannot be longer than 255 bytes, because the sizeì
  762. value is stored in the environment descriptor as a byte rather than as a word. ì
  763. The command line pointer, however, is a full word, and so extension to longerì
  764. command lines would be quite possible (I'll keep that in mind for Z35!).
  765.  
  766.      Following this line of reasoning, I am coming to the conclusion that onlyì
  767. programs like history shells and true menu shells should be implemented asì
  768. ZCPR3-style shells.  Other programs, like ZFILER and WordStar should use theì
  769. ZCPR2 style.  If I am missing some important point here, I hope that readersì
  770. will write in to enlighten me.
  771.  
  772.  
  773. Forming a Synthesis
  774.  
  775. è     So long as the command line buffer is fixed at its present length and soì
  776. long as 128 bytes are set aside as a shell stack, one should make the best ofì
  777. the situation.  Rob Wood has come up with a fascinating concept that does justì
  778. that.
  779.  
  780.      Rob was working on Steve Cohen's W (wildcard) shell.  He recognized thatì
  781. on many occasions one wants to perform a wildcarded operation followed by someì
  782. additional commands (just as with the WordStar example followed by PPIP).  As aì
  783. ZCPR3-type shell, W could not do this.  It always executed what it was supposedì
  784. to do after the wild operation before the wild operation!
  785.  
  786.      Rob came up with a brilliant way to combine the ZCPR2 and ZCPR3 shellì
  787. concepts.  When his version of W is invoked manually by the user, it pushes itsì
  788. name, as a good ZCPR3 shell does, onto the shell stack.  But it does not thenì
  789. return to the command processor to execute commands pending in the commandì
  790. line.  It starts running immediately, doing the thing it was asked to do andì
  791. using the shell stack entry to maintain needed data.
  792.  
  793.      In the course of operation, however, it does one unusual thing.  Afterì
  794. each command that it generates and passes to the command line buffer, itì
  795. appends its own name, as a good ZCPR2 shell does.  This command serves as aì
  796. separator between the shell-generated commands and those that were on theì
  797. original command line after the W command.  After the shell-generated commandsì
  798. have run, W starts to run.  It checks the top of the shell stack, and if itì
  799. finds its own name there, it says "Aha, I'm a shell," and proceeds to use theì
  800. information in the shell stack to generate the next set of commands.  Thisì
  801. process continues until W has no more work to do.  Then it pops its name offì
  802. the shell stack and returns to the command processor.  The commands originallyì
  803. included after the W command are still there and now execute exactly asì
  804. intended.  Beautiful!
  805.  
  806.  
  807. WordStar Shell Bugs
  808.  
  809.      It is bad enough that WordStar's conceptual implementation as a shell isì
  810. flawed.  On top of that, the shell code was not even written correctly.  Theì
  811. person who wrote the code (not MicroPro's fault, I would like to add) tried toì
  812. take a short cut and flubbed it.  When a shell installs itself, it shouldì
  813. always -- I repeat, always -- push itself onto the stack.  WordStar tries toì
  814. take the following shortcut.  If it sees that the shell stack is currentlyì
  815. empty, it just writes its name into the first entry, leaving the other entriesì
  816. as they were.
  817.  
  818.      When WordStar terminates, however, it pops the stack.  At this pointì
  819. whatever junk was in the second shell stack entry becomes the currently runningì
  820. shell.  The coding shortcut (which I would think took extra code rather thanì
  821. less code, but that is beside the point) assumed that if the current shellì
  822. stack entry was null, all the others would be, too.  But this need not be theì
  823. case at all.  And in many cases it has not in fact been the case, and veryì
  824. strange behavior has been observed with WordStar.  Some users have reportedì
  825. that WordStar works on their computers only if invoked from a shell!  That isì
  826. because WordStar properly pushes itself onto the stack in that case.
  827. è
  828.      There are basically two strategies one can take for dealing with the shellì
  829. problems in WordStar.  One is to fix the above problem and live with the otherì
  830. anomalies (just don't ever put commands after WS in a multiple command line). ì
  831. The other is to disable the shell feature entirely.
  832.  
  833.      To fix the bug described above, Rick Charnes wrote a program calledì
  834. SHELLINI to initialize the shell stack before using WordStar.  On bulletinì
  835. boards in the past both Rick and I presented aliases that one can use toì
  836. disable the shell stack while WS is running and to reenable it after WS hasì
  837. finished.  I will now describe patches that can be made directly to WordStarì
  838. itself.  First I will explain what the patches do; later I will discuss how toì
  839. install them.
  840.  
  841.      Listing 2 shows a patch I call WSSHLFIX that will fix the bug justì
  842. described.  The code assumes that you do not already have any initialization orì
  843. termination patches installed.  If you do, you will have to add the routinesì
  844. here to the ones you are already using.
  845.  
  846.      The patch works as follows.  When WS starts running, the initializationì
  847. routine is called.  It extracts the shell stack address from the ENV descriptorì
  848. and goes there to see if a shell command is on the stack.  If there is, noì
  849. further action is required, since WS already works correctly in this case.  If,ì
  850. on the other hand, the first shell entry is null, then the routine calculatesì
  851. the address of the beginning of the second shell entry and places a zero byteì
  852. there.  When this stack entry is popped later, it will be inactive.
  853.  
  854.      Listing 3 shows a patch I call WSSHLOFF that will completely disable theì
  855. shell feature of ZCPR3 while WS is running.  It works as follows.  When WSì
  856. starts running, the initialization routine is called.  It gets the number ofì
  857. shell stacks defined for the user's system in the ENV descriptor and saves itì
  858. away in the termination code for later restoration.  Then it sets the value toì
  859. 0.  WordStar later checks this value to see if the shell feature is enabled inì
  860. ZCPR3.  Since WordStar thinks that there is no shell facility, it operates theì
  861. 'R' command as it would under CP/M.  Later, on exit from WS, the terminationì
  862. routine restores the shell-stack-number so that normal shell operation willì
  863. continue upon exit from WS.
  864.  
  865.      The easiest way to install these patches is to assemble them to HEX filesì
  866. and use the following MLOAD command (MLOAD is a very useful program availableì
  867. from remote access systems such as Z Nodes):
  868.  
  869.     MLOAD WS=WS.COM,WSSHLxxx
  870.  
  871. Substitute the name you use for your version of WordStar and the name of theì
  872. patch you want to install.  That's it; you're all done.
  873.  
  874.      If you do not have MLOAD, you can install the patches using the patchingì
  875. feature in WSCHANGE.  From the main menu select item C (Computer), and fromì
  876. that menu select item F (Computer Patches).  From that menu, work through itemsì
  877. C (initialization subroutine), D (un-initialization subroutine), and E (generalì
  878. patch area), installing the appropriate bytes listed in Table 1.
  879. è
  880.  
  881. Summary
  882.  
  883.      We have covered a lot of material this time.  The issue of shells is aì
  884. very tricky one, and I hope to hear from readers with their comments.  I wouldì
  885. also enjoy learning about interesting ARUNZ aliases that you have created.
  886.  
  887.  
  888. =============================================================================
  889.  
  890. ; Program:    WSSHLFIX
  891. ; Author:    Jay Sage
  892. ; Date:        March 26, 1988
  893.  
  894. ; This code is a configuration overlay to correct a problem in the shell
  895. ; handling code in WordStar Release 4.
  896. ;
  897. ; Problem:  WS takes a mistaken shortcut when installing its name on the shell
  898. ; stack.  If the stack is currently empty, it does not bother to push the
  899. ; entries up.  However, when it exits, it does pop the stack, at which point
  900. ; any garbage that had been in the stack becomes the active shell.  This patch
  901. ; makes sure that the second stack entry is null in that case.
  902.  
  903. ;---- Addresses
  904.  
  905. initsub    equ    03bbh
  906. exitsub    equ    03b3h
  907. morpat    equ    045bh
  908.  
  909. ;---- Patch code
  910.  
  911.     org    initsub        ; Initialization subroutine patch
  912.  
  913. init:    jp    initpatch
  914.  
  915. ;----
  916.  
  917.     org    morpat        ; General patch area
  918.  
  919. initpatch:            ; Initialization patch
  920.     ld    hl,(109h)    ; Get ENV address
  921.     ld    de,1eh        ; Offset to shell stack address
  922.     add    hl,de        ; Pointer th shell stack address in HL
  923.     ld    e,(hl)        ; Address to DE
  924.     inc    hl
  925.     ld    d,(hl)
  926.     ld    a,(de)        ; See if first entry is null
  927.     or    a
  928.     ret    nz        ; If not, we have no problem
  929.     inc    hl        ; Advance to ENV pointer to
  930.     inc    hl        ; ..size of stack entry
  931. è    ld    l,(hl)        ; Get size into HL
  932.     ld    h,0
  933.     add    hl,de        ; Address of 2nd entry in HL
  934.     ld    (hl),0        ; Make sure that entry is null
  935.     ret
  936.  
  937.     end
  938.  
  939. Listing 2.  Source code for a patch to fix the bug in the coding of shell
  940. stack pushing and popping in WordStar Release 4.
  941.  
  942. =============================================================================
  943.  
  944. ; Program:    WSSHLOFF
  945. ; Author:    Jay Sage
  946. ; Date:        March 26, 1988
  947.  
  948. ; This code is a configuration overlay to correct a problem in the shell
  949. ; handling code in WordStar Release 4.
  950. ;
  951. ; Problem:  Because WordStar runs as a ZCPR3 shell, it is impossible to use
  952. ; WS in a multiple command line with commands intended to execute after WS is
  953. ; finished.  One can disable this by patching the ZCPR3 environment to show
  954. ; zero entries in the shell stack while WS is running.  This effectively
  955. ; disables WS4's shell capability.  Unfortunately, it means that the extended
  956. ; features of the 'R' command under ZCPR3 are also lost.
  957.  
  958. ;---- Addresses
  959.  
  960. initsub    equ    03bbh
  961. exitsub    equ    03beh
  962. morpat    equ    045bh
  963.  
  964. ;---- Patch code
  965.  
  966.     org    initsub        ; Initialization subroutine
  967.  
  968. init:    jp    initpatch
  969.  
  970. ;----
  971.  
  972.     org    exitsub        ; Un-initialization subroutine
  973.  
  974. exit:    jp    exitpatch
  975.  
  976. ;----
  977.  
  978.     org    morpat        ; General patch area
  979.  
  980. initpatch:            ; Initialization patch
  981.     call    getshls        ; Get pointer to shell stack number
  982.     ld    a,(hl)        ; Get number
  983. è    ld    (shstks),a    ; Save it for later restoration
  984.     ld    (hl),0        ; Set it to zero to disable shells
  985.     ret
  986.  
  987. exitpatch:            ; Termination patch
  988.     call    getshls        ; Get pointer to shell stack number
  989. shstks    equ    $+1        ; Pointer for code modification
  990.     ld    (hl),0        ; Value supplied by INITPATCH code
  991.     ret
  992.  
  993. getshls:
  994.     ld    hl,(109h)    ; Get ENV address
  995.     ld    de,20h        ; Offset to number of shell entries
  996.     add    hl,de        ; HL points to number of shell entries
  997.     ret
  998.  
  999.     end
  1000.  
  1001.  
  1002. Listing 3.  Source code for a patch that disables the shell feature of
  1003. ZCPR3 while WordStar 4 is running and reenables it on exit.
  1004.  
  1005. =============================================================================
  1006.  
  1007. WSSHLFIX patch bytes:
  1008.  
  1009.   initialization subroutine:    C3 5B 04
  1010.  
  1011.   un-initialization subroutine:    00 00 C9  (should be this way already)
  1012.  
  1013.   general patch area:        2A 09 01 11 1E 00 19 5E 23 56 1A
  1014.                 B7 C0 23 23 6E 26 00 19 36 00 C9
  1015.  
  1016.  
  1017. WSSHLOFF patch bytes
  1018.  
  1019.   initialization subroutine:    C3 5B 04
  1020.  
  1021.   un-initialization subroutine:    C3 65 04
  1022.  
  1023.   general patch area:        CD 6B 04 7E 32 69 04 36 00 C9 CD 6B
  1024.                 04 36 00 C9 2A 09 01 11 20 00 19 C9
  1025.  
  1026.  
  1027. Table 1.  List of HEX bytes for installing either of the patches into
  1028. WordStar Release 4 to deal with the problems in the shell code.
  1029.  
  1030. [This article was originally published in issue 33 of The Computer Journal,
  1031. P.O. Box 12, South Plainfield, NJ 07080-0012 and is reproduced with the
  1032. permission of the author and the publisher. Further reproduction for non-
  1033. commercial purposes is authorized. This copyright notice must be retained.
  1034. (c) Copyright 1988, 1991 Socrates Press and respective authors]
  1035. è