home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / tcj / tcj28.mag < prev    next >
Encoding:
Text File  |  1994-09-02  |  40.3 KB  |  815 lines

  1. The ZSIG Column #4, March 9, 1987
  2.  
  3.  
  4.                               The ZSIG Corner
  5.  
  6.                                   Jay Sage
  7.  
  8.  
  9.  
  10.      For this issue I will finally get to my long promised discussion ofì
  11. techniques for customizing the Z-COM automatic installation version of theì
  12. Z-System.  Before turning to the main subject, however, there are two otherì
  13. items I would like to cover.  One is some follow-on discussion to theì
  14. material I presented last time on recursive aliases; the other is aì
  15. description of the latest ZSIG releases.
  16.  
  17.  
  18.                          More on Recursive Aliases
  19.              -------------------------
  20.  
  21.  
  22.      Art Carlson forwarded to me a letter he received from Dreas Nielsen inì
  23. response to my discussion of recursive alias techniques using VALIAS andì
  24. ARUNZ.  Dreas, well known in the ZCPR community for his excellent shellì
  25. utility programs, GETVAR and RESOLVE, took me to task for doing somethingì
  26. the hard (and not quite correct) way when there was a not-too-hard andì
  27. completely correct way to do it.  And he proved it by offering a marvelousì
  28. technique for 'recursing' aliases without any of the problems I warned aboutì
  29. with my technique.  To me this is a wonderful example of the richness ofì
  30. ZCPR3.  No matter how thoroughly one knows it, there are always significantì
  31. new techniques and applications to be discovered.  The learning andì
  32. excitement never ends!
  33.  
  34.      We will illustrate the technique using a simple example based on theì
  35. following script that is designed to display a message on the screen showingì
  36. how many times it has been run already.  The script is
  37.  
  38.     alias ONELOOP:        ECHO THIS IS LOOP NUMBER
  39.                 REG P6
  40.  
  41. As the ZCPR3 user register number 6 is incremented using the 'P'-for-plusì
  42. option, its new value is displayed on the screen.
  43.  
  44.      If we wanted to make the alias operate recursively, our first instinct,ì
  45. as described in my previous column, would be to expand it to the following:
  46.  
  47.     alias MANYLOOP:        ECHO THIS IS LOOP NUMBER
  48.                 REG P6
  49.                 ECHO DO IT AGAIN?
  50.                 IF IN
  51.                 MANYLOOP
  52.                 FI
  53.  
  54. As I explained last time, the trouble with this is that each time we runì
  55. through the loop by answering the input prompt affirmatively we go one IFìèlevel deeper and accumulate another FI on the end of the command line. ì
  56. Eventually either the command line becomes too long or, more likely, weì
  57. exceed the allowed eight levels of IF nesting.
  58.  
  59.      Dreas's idea is based on turning this alias around so that there is noì
  60. FI on the end to accumulate.  He permutes it to the beginning of the scriptì
  61. and writes the alias this way:
  62.  
  63.     alias RECURSE2:        FI
  64.                 ECHO THIS IS LOOP NUMBER
  65.                 REG P6
  66.                 ECHO DO IT AGAIN?
  67.                 IF IN
  68.                 RECURSE2
  69.  
  70. If this alias is invoked with a 'true' IF level already in effect, this willì
  71. work just fine.  The alias will drop one IF level lower at the FI command,ì
  72. do its main work, and return to the original IF level with the "IF IN"ì
  73. prompt.  If the answer is affirmative, we will be back in the very same IFì
  74. state we were in when the alias was invoked the first time.  The alias willì
  75. be re-invoked, and the whole operation will repeat.  On the other hand, ifì
  76. the answer to the prompt is negative, the alias will stop running, and weì
  77. will fall out the bottom at the same IF level as we entered originally butì
  78. in the 'false' state.
  79.  
  80.      To deal with the need to enter one IF level higher and to terminate theì
  81. 'false' IF state at the end, we simply call the above alias from anotherì
  82. alias with the following script:
  83.  
  84.     alias RECURSE:        IF TRUE
  85.                 RECURSE2
  86.                 FI
  87.  
  88. The "IF TRUE" command will push us one IF level deeper and put us in aì
  89. 'true' state.  (This, by the way, is the first time that I have ever seen aì
  90. use for the "TRUE" option with the IF command.  If, like me, you neverì
  91. implemented that option because you could not figure out what on earth itì
  92. could possibly be used for, you can substitute any other option that isì
  93. guaranteed to return a 'true' state, such as "IF NULL" with nothing after itì
  94. or "IF A=A").  The RECURSE2 alias will now run as we described earlier, andì
  95. when the recursion is terminated by a negative answer, the FI in RECURSEì
  96. will terminate the resulting 'false' IF state and return us to the originalì
  97. IF level that we were at when RECURSE was invoked.
  98.  
  99.      One has to stretch things a bit to come up with any disadvantages toì
  100. this technique.  The best I can do is the following two minor points. ì
  101. First, two aliases are required to get things started, and this will slowì
  102. things down a bit, especially on a floppy-disk system.  Secondly, theì
  103. technique, while simple in principle, may not be easy to remember when oneì
  104. wants to set up a quick recursive alias, as in the application I describedì
  105. in my last article.  The VALIAS/ARUNZ-type recursive alias may still beì
  106. useful in such a case.
  107.  
  108.      If you are a purist and have a strong, perhaps even irresistible, urgeì
  109. to do things right (and especially if you have a RAM disk so that you canìèafford to indulge such compulsions), Dreas's technique can be nicelyì
  110. automated by creating the following two slightly more complex andì
  111. generalized aliases:
  112.  
  113.     alias RECURSE        IF NULL $1
  114.                 ECHO SYNTAX: $0 ALIASNAME PARAMETERS
  115.                 ELSE
  116.                 RECURSE2 $*
  117.                 FI
  118.  
  119.     alias RECURSE2        FI
  120.                 $*
  121.                 ECHO RUN "$1" AGAIN?
  122.                 IF IN
  123.                 $0 $*
  124.  
  125. Now suppose we have our edit/assemble/link alias as follows (where it, inì
  126. turn, calls on the SYSLINK alias to perform the linkage with the libraries):
  127.  
  128.     alias WORK        EDIT $1.Z80
  129.                 Z80ASM $1/R
  130.                 IF ~ERROR
  131.                 SYSLINK $1
  132.                 FI
  133.  
  134.      If we enter the command "RECURSE" all by itself, we will get the ì
  135. message "SYNTAX: RECURSE ALIASNAME PARAMETERS".  If we enter the commandì
  136. "RECURSE WORK MYPROG",  the "IF NULL" test in RECURSE will be 'false' butì
  137. will be toggled 'true' by the ELSE command.  Then RECURSE2 will be invoked,ì
  138. and the command line and IF status will progress as shown in Fig. 1.  Theì
  139. "..." in the IF states designates any IF levels in effect at the time thatì
  140. RECURSE was called.  Similarly, the command text 'pending' designates anyì
  141. command-line text following the invocation of RECURSE.
  142.  
  143.      The figure does not show the operation of every command.  Theì
  144. edit/assemble/syslink sequences are not shown in detail.  Between steps 8ì
  145. and 9 we assume that the "IF IN" prompt was answered with a 'Y'.  Thisì
  146. brings us at step 9 back to the exact state we were in at step 4, and stepsì
  147. 4 through 8 will be repeated over and over so long as the "IF IN" prompt isì
  148. answered affirmatively.
  149.  
  150.      Between steps 10 and 11 we assume that the "IF IN" prompt was answeredì
  151. with 'N', so we get the state shown in step 11.  Since the current IF stateì
  152. is 'false', the command "RECURSE2 WORK MYPROG" is flushed, leaving us atì
  153. step 12.  The FI command terminates the 'false' IF and drops the flow stateì
  154. one level lower.  Any pending commands that were on the command line afterì
  155. the invocation of RECURSE are now free to run at step 13.
  156.  
  157.      I just tested out these aliases on my SB180 by putting them into myì
  158. ALIAS.CMD file, which lives on the RAM disk.  The scripts had to be alteredì
  159. slightly, with all invocations of RECURSE2 from within RECURSE and RECURSE2ì
  160. being replaced by "ARUNZ RECURSE2 ..." or "ARUNZ $0 ...".  They worked likeì
  161. an absolute charm.  Thank you Dreas Nielsen!!!
  162.  
  163. ------------------------------------------------------------------------------
  164. è
  165.     Step    IF state    Command Buffer Contents
  166.     ----    --------    -----------------------
  167.  
  168.       1    ...        RECURSE WORK MYPROG;pending
  169.  
  170.       2    ...        IF NULL WORK MYPROG;ECHO SYNTAX: RECURSE
  171.                 ALIASNAME PARAMETERS;ELSE;RECURSE2 WORK
  172.                 MYPROG;FI;pending
  173.  
  174.       3    F...        ELSE;RECURSE2 WORK MYPROG;FI;pending
  175.  
  176.       4    T...        RECURSE2 WORK MYPROG;FI;pending
  177.  
  178.       5    T...        FI;WORK MYPROG;ECHO RUN "WORK" AGAIN?;
  179.                 IF IN;RECURSE2 WORK MYPROG;FI;pending
  180.  
  181.       6    ...        WORK MYPROG;ECHO RUN "WORK" AGAIN?;IF IN
  182.                 RECURSE2 WORK MYPROG;FI;pending
  183.  
  184.       7    ...        EDIT MYPROG.Z80;Z80ASM MYPROG/R;IF ~ERROR;
  185.                 SYSLINK MYPROG;FI;ECHO RUN "WORK" AGAIN?;
  186.                 IF IN;RECURSE2 WORK MYPROG;FI;pending
  187.  
  188.       8    ...        ECHO RUN "WORK" AGAIN?;IF IN;RECURSE2 WORK
  189.                 MYPROG;FI;pending
  190.  
  191.       9    T...        RECURSE2 WORK MYPROG;FI;pending
  192.  
  193.      10    ...        ECHO RUN "WORK" AGAIN?;IF IN;RECURSE2 WORK
  194.                 MYPROG;FI;pending
  195.  
  196.      11    F...        RECURSE2 WORK MYPROG;FI;pending
  197.  
  198.      12    F...        FI;pending
  199.  
  200.      13    ...        pending
  201.  
  202. Fig. 1.  Evolution of the command line and IF states as the operation of theì
  203. command "RECURSE WORK MYPROG" unfolds.
  204.  
  205. ------------------------------------------------------------------------------
  206.  
  207.  
  208.                             A Z-Letters Feature
  209.                 -------------------
  210.  
  211.  
  212.      Thanking Dreas Nielsen for his letter reminds me that Art Carlson and Iì
  213. would like very much to start up a Z-Letters feature in TCJ, a kind ofì
  214. letters-to-the-editor section specializing in Z-System questions, comments,ì
  215. discussion, and ideas.  I am willing to handle answering or otherwiseì
  216. responding to those letters, but I will depend on you readers to send themì
  217. in.  And rest assured that we are not looking only for letters like Dreas'sì
  218. containing brilliant suggestions.  A good set of simpleminded questionsìèwould be quite well appreciated, thank you.  They would help us a great dealì
  219. in learning what aspects of Z-System are confusing to users so that we canì
  220. try to clarify them.
  221.  
  222.  
  223.                              New ZSIG Releases
  224.                  -----------------
  225.  
  226.  
  227.      We have quite a few excellent new programs to release on ZSIG diskettesì
  228. this month.  I have not yet finalized exactly what will be included onì
  229. release diskettes #2 and #3, but I don't want to pass up this opportunity toì
  230. publicize them.
  231.  
  232.      First of all, I am very happy to report that all the programs Iì
  233. proposed two issues back have now been written, and I will describe themì
  234. first.
  235.  
  236. K;S4;I4
  237. FCP10.LBR
  238.  
  239.     This is the new flow control package (FCP) that I wrote with valuableì
  240. assistance from Howard Goldstein (New Haven, CT).  This program wasì
  241. described in some detail in the last column, so I will not say too muchì
  242. about it here.  The two most important innovations are 1) the additionì
  243. of AND and OR commands and 2) the FCP's ability to load and run IF.COMì
  244. in high memory where it will not interfere with data in the beginning ofì
  245. the transient program area at 100H.
  246.  
  247. COMIF10.LBR
  248.  
  249.     This is the companion transient IF processor that is intended to replaceì
  250. IF.COM.  Also described last time, it offers an enormous number of newì
  251. test conditions and syntax forms. This one was also written by meì
  252. together with Howard Goldstein.
  253.  
  254. SETPATH1.LBR
  255.  
  256.     This is an extended version of the original PATH command.  It allows oneì
  257. optionally to add and remove path elements from the beginning or the endì
  258. of the existing path.  The path display is also improved.  Robertì
  259. Demrow, a fellow member of the Boston Computer Society CP/M Group wroteì
  260. this one.
  261.  
  262. EDITND.LBR
  263.  
  264.     Al Hawley (Z-Node #3 in Los Angeles) really went all out with tools toì
  265. work with the named directory register (NDR).  EDITND lets one edit theì
  266. names directly in the NDR.  Names and/or passwords can be added,ì
  267. deleted, and changed.
  268.  
  269. SAVNDR.LBR
  270.  
  271.     After you've edited the NDR, this program lets you save the results toì
  272. an NDR file.  Again by Al Hawley.
  273. è
  274. LOADND12.LBR
  275.  
  276.     The last in the Hawley set, this program can automatically update theì
  277. names in the NDR using either the special file name system in LDSK or byì
  278. loading an NDR file whose names are applied to the current floppy diskì
  279. only.
  280.  
  281.  
  282. The next ZSIG release will also include the following programs.
  283.  
  284. ZPATCH11.LBR
  285.  
  286.     This is another masterpiece from Steve Cohen (Chicago, author of 'W',ì
  287. the wildcard shell, on the first ZSIG diskette).  It is by far the bestì
  288. file patcher I have ever seen -- a real joy to use.  Steve sure isì
  289. clever when it comes to shells!  Who would have thought to make a fileì
  290. patcher into a shell?  But this way one can run a command from insideì
  291. ZPATCH and then return to one's exact place to continue working.  Theì
  292. 'X' command in ZPATCH automatically runs the file one is currentlyì
  293. patching (provided it is a COM file) so that one can see the effect ofì
  294. the changes.  Marvelous!
  295.  
  296. MEX2Z.LBR
  297.  
  298.     This is yet another brainstorm of NAOG chief Bruce Morgen (who has quiteì
  299. a stormy brain).  MEX2Z and my adaptation of it for MEX-Plus, MEX+2Z,ì
  300. give the MEX communication programs the ability to 'shell', that is, toì
  301. run a Z-System command apparently from within MEX.  For example, if youì
  302. enter the MEX command line "CPM;CRUNCH FN.FT", you will exit from MEX,ì
  303. the file will be crunched, and then you go right back into MEX.  This isì
  304. especially handy when you are trying to debug a MEX script.  Bruceì
  305. picked up on the very clever trick introduced by Ted Emigh in FINDERR,ì
  306. namely, running a program that examines information left behind inì
  307. memory by the program that ran before it.  In this case it is the MEXì
  308. command line buffer that is picked up.  Even if you don't use MEX, it isì
  309. worth looking at these programs just for their educational value.
  310.  
  311. FF10.LBR
  312.  
  313.     I finally decided to do something about the shortcomings of FINDF, theì
  314. utility for determining where files are located in your system.  FF hasì
  315. a 16-bit configuration word that can be patched (roll out ZPATCH!) toì
  316. define which drives should be searched by default (this is particularlyì
  317. useful when your constellation of drives has a hole in it, such as A, B,ì
  318. C, and F).  You can override the default drive list by specifying a setì
  319. of drives to scan on the command line.  A whole list of fileì
  320. specifications can be given, and each one is automatically wildcarded,ì
  321. saving the user a lot of typing.  If you want to find all programsì
  322. starting with "SD", just enter "FF SD".  The "SD" turns into "SD*.*"ì
  323. automatically.  Similarly, "FF .LBR" will find all library files.  "FFì
  324. SD,.LBR" will find both.
  325.  
  326. PPIP15.LBR
  327.  
  328. è    This is the next step in the evolution of PPIP (PPIP14 is on ZSIGì
  329. diskette #1).  The main addition is support for DateStamper time andì
  330. date stamping.  Having fallen in love with DateStamper, I just had toì
  331. have some file copying tools that would preserve the time and dateì
  332. information, so I added that capability to PPIP and to ZFILER.
  333.  
  334. ERRSET11.LBR
  335.  
  336.     This little tool lets you either display the current or directly enter aì
  337. new error handler command line.  Strictly speaking, error handling inì
  338. ZCPR3 is not performed by loading an error handling program but byì
  339. executing an error handling command line.  This command line is storedì
  340. in a 16-byte string in the message buffer.  When an error handler isì
  341. installed by invoking its name manually from the command line, it writesì
  342. only its name alone into that buffer.  ERRSET lets you enter a completeì
  343. error command line, such as A15:VERROR.  By including an explicit DU: orì
  344. DIR: form, the error handler will be found and loaded faster.  On theì
  345. other hand, ERRSET will let you enter the name of a nonexistent errorì
  346. handler, so watch out.  Power has its price.  Written by yours truly.
  347.  
  348.  
  349. 
  350. R76;I8
  351.                              Customizing Z-COM
  352.                  -----------------
  353.  
  354.  
  355.      We now turn to the piece-de-resistance for this article -- a discussionì
  356. of techniques for customizing Echelon's automatically installing Z-Systemì
  357. package known as Z-COM.  This will be the first of a two-part series.  Thisì
  358. time I will cover the more elementary aspects of the subject, thoseì
  359. modifications that can be made by changing only data structures in the Z-COMì
  360. files.  Next time I will delve into customization techniques that involveì
  361. serious hacking (such as modifying the Z-COM code itself).
  362.  
  363.      I will begin with an overview of what Z-COM is, the philosophy behindì
  364. it, the procedure for installing it on a particular computer, and how oneì
  365. uses it to create a Z-System automatically.  Then I will give an elementaryì
  366. discussion of how it works and the structure of the COM file that magicallyì
  367. transforms one's ordinary CP/M machine into a 'Z' machine.  Next I will showì
  368. you how to make some simple patches that eliminate the initializationì
  369. operations that are performed by the startup file and make Z-COM come upì
  370. ready to go instantly.  This includes setting the wheel byte, defining theì
  371. symbolic command search path, putting in the terminal capability descriptorì
  372. (TCAP) for the user's terminal, installing the user's named directories,ì
  373. installing an external error handler, and even setting up an initial shell.
  374.  
  375.      With those techniques mastered, we can then go on to make changes toì
  376. the system modules.  The simplest of these is replacing the standard ZRDOSì
  377. that comes with Z-COM with the latest-and-greatest Public-ZRDOS-Plus versionì
  378. 1.7.   Slightly more complex is the replacement of the environmentì
  379. descriptor (ENV) and the two command modules: the RCP (resident commandì
  380. package) and the FCP (flow control package).  For these changes we have toì
  381. edit some configuration files, assemble new code modules, and install theì
  382. new modules into the Z-COM file.  By this point you will be ready toìègenerate and install a new version of the ZCPR3 command processor, anì
  383. operation that requires one important extra step (a simple one, but one thatì
  384. must not be overlooked).
  385.  
  386.  
  387.                                  Why Z-COM
  388.  
  389.  
  390.      Consider this situation.  The Z-System is a wonderful replacement forì
  391. CP/M, one that greatly enhances the utility and ease of operation of anì
  392. 8-bit Z80-compatible computer.  I can't understand why anyone would notì
  393. enjoy and benefit from its features and capabilities.  However, installingì
  394. it in the conventional fashion required changing the BIOS (Basic Inputì
  395. Output System), the hardware-dependent part of the operating system. ì
  396. Unfortunately, many (actually most) manufacturers consider their BIOS to beì
  397. proprietary (or embarrassingly poorly written), and they refuse to releaseì
  398. the source code.  And even if they do make it available, perhaps for anì
  399. extra fee, what if you do not know how to make the required changes toì
  400. support the ZCPR3 command processor?  Well, enter Z-COM.
  401.  
  402.      Z-COM was the brilliant conception of Joe Wright, the nation'sì
  403. preeminent BIOS writer (author of the BIOSes for the Ampro Little Board,ì
  404. Micromint SB180, and the soon-to-be-available ON! computer from Oneac). ì
  405. With Z-COM one does not need the BIOS source code because there are noì
  406. changes to make in it.  One doesn't even need MOVCPM.  Z-COM runs on almostì
  407. any standard CP/M 2.2 system, converting it in situ to a Z-System.  Thereì
  408. are a few CP/M 2.2 computers on which Z-COM will not work (usually becauseì
  409. at least some part of their memory space operates in a funny way), but theì
  410. great majority will.  For those of you with CP/M version 3 (aka CP/M-Plus --ì
  411. a real misnomer in my opinion), I'm afraid you are out of luck.  CP/M 3 isì
  412. fundamentally different from CP/M 2.2, and no one has yet been able toì
  413. concoct magic powerful enough to transform it into a Z-System.
  414.  
  415.      I hope my discussion here will inspire some of you to purchase Z-COM. ì
  416. If it does, then see the ads in TCJ by Sage Microsystems East and Echelonì
  417. for more information.  I personally think that a modified Z-COM is the bestì
  418. way to implement Z-System, because, as we will see by the end of this seriesì
  419. of articles, it gives one far greater flexibility than with a manuallyì
  420. installed system.
  421.  
  422.  
  423.                               Installing Z-COM
  424.  
  425.  
  426.      Here is a brief description of how one gets Z-COM running on one'sì
  427. system.  The standard procedure goes like this.  Take a freshly formattedì
  428. disk, 'sysgen' the CP/M 2.2 operating system to it, copy onto it all theì
  429. files on the Z-COM release disk, put this disk into drive A, and reboot theì
  430. system either with the reset button or by entering control-c.  Now enter theì
  431. command "SUB ZCCOM".  This starts a batch operation, and you can now sitì
  432. back, relax, and watch your computer do all the work.  Toward the end of theì
  433. process, which takes a couple of minutes, a program called TCSELECT will runì
  434. and ask you to choose your terminal from a large menu.  The result will be aì
  435. file called MYTERM.Z3T containing information about your terminal thatì
  436. permits Z-System programs to perform screen operations without installation.
  437. è
  438.  
  439.                     What's Going On During Installation
  440.  
  441.  
  442.      In the first part of the installation process, the Z-COM systemì
  443. creation program ZCLD.COM determines the memory address at which your BIOSì
  444. operates and generates a corresponding Z-System.  To do this, it reads in aì
  445. number of special relocatable files (most with file type SPR, which standsì
  446. for system page relocatable) and produces four new files: ZC.COM, ZCX.COM,ì
  447. ZC.ENV, and ZC.CP.  The first file, whose operation we will describe inì
  448. detail below, is the one that transforms the vanilla CP/M system to theì
  449. amaretto-double-chocolate almond Z-System with jimmies (if you don't knowì
  450. what jimmies are, ask someone from Boston).
  451.  
  452.      The second file, ZCX.COM, is a program that transforms you back.  Why,ì
  453. you ask, would one ever go back to vanilla after experiencing the ecstasy ofì
  454. amaretto-double-chocolate-almond?  Well, Z-System does have one significantì
  455. drawback.  You don't get all those great features for free.  They cost aì
  456. considerable chunk of TPA (transient program area) -- 5.5K in the case of Z-COM (though we will see next time how to reduce this if you are willing toì
  457. forego some of the features).  The smaller TPA has almost never caused anyì
  458. problem with the programs I use, but some people do have problems, and it isì
  459. nice to know that a simple "ZCX" command will bring back the old CP/M withì
  460. its full-sized TPA.  Next time I will explain how we can even change to aì
  461. different Z-COM system with a larger TPA.
  462.  
  463.      The third file, ZC.ENV, is the environment descriptor file for theì
  464. system that ZCLD created.  It is automatically included in ZC.COM, so itì
  465. does not have to be loaded using LDR, but it is used by Z3INS to install theì
  466. environment information into the utilities.
  467.  
  468.      The last file, ZC.CP, does not even appear in a directory listing; itì
  469. is hidden up in user area 15, out of harm's way.  The user is not normallyì
  470. concerned with this file, though if you want to create another Z-COM systemì
  471. disk, you have to remember to copy it, as well as the others mentionedì
  472. above, to the new diskette.  We will discuss its purpose later.
  473.  
  474.  
  475.                               How ZC.COM Works
  476.  
  477.  
  478.      As we said above, ZC.COM is the program that transforms your mundaneì
  479. CP/M system into an exciting and powerful Z-System.  How does it do it? ì
  480. Several simple principles are involved.
  481.  
  482.      ZC.COM is basically a loader program.  The file itself consists of twoì
  483. parts.  The first page of code (100H to 1FFH) is the loader code.  Theì
  484. second part (200H to 2DFFH) is the memory image of a Z-System that is copiedì
  485. into place by the loader.  The process is like the 'big bang' theory ofì
  486. creation -- the whole Z-System just appears complete in one operation!
  487.  
  488.      The memory map of the ZCOM-System generated for my BigBoard I computer,ì
  489. on which I performed these experiments, is shown in Fig. 2.  Its real CP/Mì
  490. BIOS is at E800H.  The Z-System addresses were determined by running theì
  491. utility SHOW.COM after Z-COM was loaded.  The corresponding addresses in theìèZC.COM file were obtained by inspecting it with a debugger.  Once a fewì
  492. addresses (like the RCP and FCP, which have obvious headers), wereì
  493. determined, the rest was obvious.  The ZC.COM system image is at a constantì
  494. offset from the real system.  In this example, that offset is BA00H.  If Z-COM is installed on a different system, the real system addresses and theì
  495. offset value will be different, but the addresses of the system segments inì
  496. the ZC.COM image will be the same.  In general, the offset between theì
  497. corresponding addresses will be 2E00H less that the address of the nativeì
  498. BIOS.
  499.  
  500. -----------------------------------------------------------------------------
  501.  
  502. System Component        ZC.COM Address        System Address
  503. ----------------        --------------        --------------
  504.  
  505.   CPR                  0200 - 09FF          BC00 - C3FF
  506.   ZRDOS                  0A00 - 17FF          C400 - D1FF
  507.   Virtual BIOS              1800 - 19FF          D200 - D3FF
  508.   Named Directory Register      1A00 - 1AFF          D400 - D4FF
  509.   Shell Stack              1B00 - 1B7F          D500 - D57F
  510.   Z3 Message Buffer          1B80 - 1BCF          D580 - D5CF
  511.   External FCB              1BD0 - 1BF3          D5D0 - D5F3
  512.   PATH                  1BF4 - 1BFE          D5F4 - D5FE
  513.   Wheel Byte              1BFF - 1BFF          D5FF - D5FF
  514.   Environment Descriptor      1C00 - 1C7F          D600 - D67F
  515.   TCAP                  1C80 - 1CFF          D680 - D6FF
  516.   Multiple Command Line          1D00 - 1DCF          D700 - D7CF
  517.   External Stack          1DD0 - 1DFF          D7D0 - D7FF
  518.   Resident Command Package      1E00 - 25FF          D800 - DFFF
  519.   Flow Control Package          2600 - 27FF          E000 - E1FF
  520.   I/O Package              2800 - 2DFF          E200 - E7FF
  521.  
  522. Fig. 2.  Addresses of system components in the ZC.COM file and in theì
  523. example system for which it was generated.
  524.  
  525. -----------------------------------------------------------------------------
  526.  
  527.      How does this system function?  If you are familiar with Z systems, youì
  528. probably recognize all of the system components above except for the oneì
  529. called 'virtual BIOS'.  That is where the key to Z-COM lies.  Remember, weì
  530. needed a BIOS that would run below the Z buffers, but we had no way toì
  531. relocate the actual BIOS.  So instead we create a virtual BIOS -- a block ofì
  532. code structured just like a real BIOS.  It has a table of jump instructions,ì
  533. one after the other, that perform the required BIOS functions: CBOOT, WBOOT,ì
  534. CONST, CONIN, CONOUT, LIST, and so on.  How does this virtual BIOS actuallyì
  535. carry out those functions without knowing anything about the systemì
  536. hardware?  Easy!  It simply jumps to the corresponding entry points in theì
  537. real BIOS!
  538.  
  539.      Well, it actually is not quite that easy.  There are a few specialì
  540. details that have to be taken care of.  Most of the functions are performedì
  541. as described above, but there are some important exceptions.  The mostì
  542. important one is the WBOOT, or warm boot, function.  Normally when a warmì
  543. boot is performed, the CPR (and often the BDOS as well) is reloaded from theì
  544. system tracks of the A diskette.  If that were allowed to happen here,ì
  545. goodbye Z-System!  ZC.COM would only work until the first warm bootìèoccurred, and then we would have to run it again.  Not very satisfactory!
  546.  
  547.      To prevent that from happening and to keep Z-COM running, the virtualì
  548. BIOS 'traps' warm boot calls.  That is a fancy way of saying that instead ofì
  549. simply passing the call to the real BIOS it does the work itself.  What doesì
  550. it do?  Well, it has to reload the ZCPR3 command processor to the properì
  551. address, BC00H in this example.  Since the ZCPR command processor does notì
  552. reside on the system tracks, we have to get it from somewhere else.  Joeì
  553. Wright could have gotten it from records 2 through 17 in ZC.COM, but heì
  554. chose instead to maintain a separate file with just the image of the commandì
  555. processor.  Remember the file ZC.CP that we mentioned earlier, the oneì
  556. stashed away in A15:?  That's it.
  557.  
  558.      Although I don't know of any reason why CBOOT, the cold boot routine,ì
  559. would ever be called once the computer was initially booted up, the CBOOTì
  560. routine is also trapped by the virtual BIOS and vectored (another fancyì
  561. word) to the same code as the virtual warm boot.
  562.  
  563.      In Echelon's simpler auto-install package Z3-DOT-COM, which does notì
  564. have support for Input/Output Packages (IOPs), the story would now beì
  565. complete.  The IOP, however, has to get first shot at some of the BIOS I/Oì
  566. routines, namely console status, console input, console output, list output,ì
  567. list status, punch output, and reader input.  In a manual installation of Z-System with IOP support, the BIOS code would have to be modified.  With Z-COM this is quite straightforward.  The virtual BIOS calls to theseì
  568. functions simply go (are vectored) to the appropriate entry points in theì
  569. IOP module.  The initial IOP code included in ZC.COM is just a dummy IOPì
  570. that simply turns around and forwards the calls from the IOP to the realì
  571. BIOS entry points.
  572.  
  573.  
  574.                              Easy Z-COM Patches
  575.  
  576.  
  577.      Now that we understand what Z-COM is and how it works, we can start toì
  578. make some changes.  If you look at the STRT startup alias with Z-COM, youì
  579. will see that it turns on the wheel byte, loads the TCAP and named directoryì
  580. register, and sets up the symbolic search path.  For our first set ofì
  581. patches, we will eliminate the need for a startup alias.  We will make theì
  582. system come up fully tailored to our preferences, and we will save the timeì
  583. wasted by the STRT alias.
  584.  
  585.      The first step is to get Z-COM running and to use the utility programsì
  586. to set it up as we like it.  We will generally turn the wheel byte on (theì
  587. STRT alias presumably already ran WHEEL to do that for us).  We can set upì
  588. our named directories using MKDIR and LDR or the new ZSIG named directoryì
  589. editor EDITND.  We can choose our path using the PATH command or the newì
  590. ZSIG SETPATH utility.  An external error handler can be defined in theì
  591. message buffer by invoking the desired error handler manually at the commandì
  592. line or by running the ERRSET utility (this can include a DU or DIRì
  593. specifier to speed up the search for the error handler).  Finally, if weì
  594. want to, we can even invoke a shell, such as the history shell HSH.
  595.  
  596.      Now all we have to do is clone this system using our favorite debugger. ì
  597. If you can afford Echelon's DSD, I cannot recommend it highly enough.  Itì
  598. will quickly spoil you.  On the other hand, I will describe here theì
  599. procedure using Prof. Falconer's lovely DDTZ, a public-domain Zilog-mnemonicìèversion of DDT.  Here is the sequence of commands to use.  Don't forget thatì
  600. the addresses that refer to the real system are the ones for my BigBoard. ì
  601. You should make a table like that in Fig. 2 with the addresses for yourì
  602. system and make the appropriate substitutions in the commands below.
  603.  
  604.     A0:SYS>ddtz zc.com        ; Run debugger and load ZC.COM
  605.     -md400,d6ff,1a00        ; Copy running NDR, Shell Stack, MSG
  606.                 ; ..buffer, PATH, WHL, ENV, and TCAP
  607.                 ; ..into ZC.COM image
  608.     -g0                ; Exit from debugger
  609.     A0:SYS>save 2dh zcnew.com    ; Save new version of ZC
  610.  
  611. If you have a shell running while this process is being carried out, youì
  612. have to include the SAVE command on the same line as the DDTZ command, sinceì
  613. when the shell loads it wipes out the memory image in the TPA.  By puttingì
  614. the SAVE command on the same line, it is run before the shell is reloaded.
  615.  
  616.      I have used the above technique and found it to work very nicely, but aì
  617. word of caution is in order.  A purist would copy the memory areas only forì
  618. the specific segments to be modified.  The external file control block andì
  619. the parts of the message buffer other than the byte at offset 0 (D580, whereì
  620. the error-handler-flag is kept) and bytes at offsets 10H to 1FH (D590-D59F,ì
  621. where the error handler command line is kept) would not be copied.  Copyingì
  622. the entire message buffer works as described above, but if you try to make aì
  623. ZEX batch file to do this, you will get into trouble, since ZCNEW.COM willì
  624. then contain an image of the message buffer with the ZEX-running flag set.
  625.  
  626.      To test ZCNEW, make a new STRT.COM alias that just echoes a signonì
  627. message (first rename the old one in case you want it back later), run ZCXì
  628. to exit from Z-COM, and then run ZCNEW.  Your own personalized Z-Systemì
  629. should pop (almost) instantly to life.  After determining that it is reallyì
  630. working correctly, you can rename ZCNEW.COM to ZC.COM.  Again, I recommendì
  631. keeping old versions with names like ZC1.COM, ZC2.COM, and so on, on anì
  632. archive disk.
  633.  
  634.  
  635.                             Putting in a New DOS
  636.  
  637.  
  638.      Now let's make a change that could not be accomplished using utilityì
  639. programs, as all of the above changes could be.  Let's replace the older,ì
  640. non-public version of ZRDOS that comes with Z-COM with the latest versionì
  641. 1.7 of Public-ZRDOS-Plus.  The first part of the process is same as that inì
  642. a manually installed Z-System.  One takes the ZRDOS generating programì
  643. ZRDINS17.COM, installs it using Z3INS, and runs it.  Having been installed,ì
  644. it will automatically know the three facts it needs: where the DOS, ENV, andì
  645. wheel byte are located.  After it finishes running, there will be a binaryì
  646. image file called ZRDOS17.BIN.
  647.  
  648.      With a manually installed Z-System we would now have to go through aì
  649. somewhat complex process involving 'sysgening' a system image from theì
  650. system tracks, patching in the new DOS using a debugger, and 'sysgening' theì
  651. image back onto the system tracks.  With Z-COM things are actuallyì
  652. considerably easier, since the two 'sysgening' steps can be skipped.  Hereì
  653. is the command sequence:
  654. è
  655.     A0:SYS>ddtz zc.com        ; Run debugger and load ZC.COM
  656.     -izrdos17.bin        ; Initialize the file control block
  657.     -r900            ; Read with offset 900h so that the object
  658.                 ; ..file will load at A00h
  659.     -g0                ; Warm boot out of debugger
  660.     A0:SYS>save 2dh zcnew.com    ; Save new version
  661.  
  662. As before, exit from Z-System with the ZCX command (or just hit the resetì
  663. button if that is more convenient).  Then load the new system and run theì
  664. DOSVER utility.  Voila!  There is version 1.7.
  665.  
  666.      Now let me show you a trick that makes patching even easier and doesn'tì
  667. require a debugger at all.  Just use the following command sequence:
  668.  
  669.     A0:SYS>get 100 zc.com    ; Load ZC.COM at address 100H
  670.     A0:SYS>get a00 zrdos17.bin    ; Load ZRDOS17.BIN at address A00H
  671.     A0:SYS>save 2dh zcnew.com    ; Save the new memory image
  672.  
  673. With this technique there is no computing of offsets, and it uses only ZCPR3ì
  674. built-in commands (GET and SAVE).  The one thing you have to remember isì
  675. that the GET command loads entire files, and so this technique can only beì
  676. used to patch in things that come in contiguous blocks with a length that isì
  677. an integral multiple of 128 bytes.  If you look at the memory table ofì
  678. ZC.COM, however, you will see that this includes all system modules thatì
  679. ever exist in the form of files: the CPR, DOS, NDR, ENV, TCAP, RCP, FCP, andì
  680. IOP.  These patches can be done very nicely from alias scripts.  Forì
  681. example, since one might often change one's named directories, the followingì
  682. alias might be handy:
  683.  
  684.     alias PUTNDR:
  685.  
  686.         IF NULL $1
  687.         ECHO SYNTAX: $0 NDR-FILE-NAME
  688.         ELSE
  689.         ERA ZCNEW.COM
  690.         GET 100 ZC.COM
  691.         GET 1A00 $1.NDR
  692.         SAVE 1DH ZCNEW.COM
  693.         ECHO TEST ZCNEW.COM
  694.         FI
  695.  
  696. Similar aliases could be used for replacing other modules such as RCPs andì
  697. FCPs.
  698.  
  699.  
  700.                        New Command and System Modules
  701.  
  702.  
  703.      Speaking of RCPs and FCPs, let's talk a little about how we generateì
  704. new versions of these and other system modules.  There is no need to discussì
  705. the patching techniques.  They are the same as what we have already seen. ì
  706. The question is: how do we generate the new SYS.RCP, SYS.FCP, and SYS.ENVì
  707. modules?
  708.  
  709. è     The procedure is the same as in a manual install system, except that inì
  710. a manual install system we already had the necessary Z3BASE.LIB file that isì
  711. required for the assembly of new system modules.  So far we have not neededì
  712. one with Z-COM.  To make things easier, Joe Wright has kindly provided usì
  713. with a generalized Z3BASE.LIB file.  All we have to do to adapt it to ourì
  714. system is to use an editor to fill in the address of the environmentì
  715. descriptor in the "Z3ENV SET ..." definition near the top of the file.  Oneì
  716. further hint: while you are at it, change the SET to an EQU.  If you useì
  717. Z3BASE.LIB to assemble a file in Zilog mnemonics, the assembler will notì
  718. accept SET, since that is a Zilog opcode.  You would have to change it toì
  719. ASET in that case, but there is no reason not to use the universal EQU. ì
  720. Some programs also require definitions for YES and NO, so you might want toì
  721. add the lines:
  722.  
  723.         YES    EQU    TRUE
  724.         NO    EQU    FALSE
  725.  
  726. One last addition.  The RCP, FCP, and ENV modules do not need it, but otherì
  727. files, and most notably the command processor code, require an equate toì
  728. define the address of the entry point to the command processor.  This is aì
  729. part of the normal Z3BASE file, but Joe Wright forgot to put it in. ì
  730. Someplace after the Z3ENV equate, add the line:
  731.  
  732.         CCP    EQU    Z3ENV - 1A00H
  733.  
  734. Now you should be all set to assemble up new system modules, like the newì
  735. FCP10 from ZSIG.  You might also want to assemble a customized SYS.ENV withì
  736. the correct values of maxdrive and maxuser and your own choice of printerì
  737. and console definitions (see "ZCPR3, The Manual" for details).
  738.  
  739.      "ZCPR3, The Manual" explains in detail how to carry out the assemblies,ì
  740. though I find that the discussion there makes the process look moreì
  741. complicated than it really is.  Basically, you assemble the module to a HEXì
  742. file, convert the HEX file to a COM file using MLOAD, and then rename theì
  743. COM file to the proper name for the module (e.g., "REN SYS.FCP=FCP10.COM). ì
  744. If you have the SLR assemblers, you can assemble the module directly to aì
  745. COM in a single pass and skip the MLOAD step.  Finally you test the moduleì
  746. by loading it using LDR.
  747.  
  748.  
  749.                       Replacing the Command Processor
  750.  
  751.  
  752.      Replacing the command processor is no more difficult than changing anyì
  753. of the other modules in the system.  In fact, as we will soon see, it isì
  754. much easier to test a new CPR with Z-COM than it is with the manuallyì
  755. installed Z-System.
  756.  
  757.      The basic procedure is as we described for the RCP or FCP.  As usual,ì
  758. edit the configuration LIB file (Z3HDR.LIB or Z31HDR.LIB if you are using myì
  759. experimental version ZCPR315D) and assemble the code.  One additional hint. ì
  760. Again, if you have the fabulous SLR Systems assemblers SLRMAC, Z80ASM, orì
  761. SLR180, select the option to assemble directly to a COM file, not to a HEXì
  762. file.  It is a shame that so many books and articles have taught theì
  763. unnecessarily complex patching method based on HEX files with theirìèextremely tricky offset calculation.  It is much easier to work with a COMì
  764. file where the load offset in the debugger is quite straightforward, namely,ì
  765. 100H below where you want the file to go, no matter what address it wasì
  766. assembled for.  If you are using an assembler that can produce only a HEXì
  767. file, then use the public-domain MLOAD to convert it to a COM file just asì
  768. was done to make the RCP and FCP files.
  769.  
  770.      Now that you have ZCPR3.COM or some such file, all you have to do isì
  771. substitute it for the file ZC.CP in A15:.  It would be a sign of foolhardyì
  772. optimism to destroy the original ZC.CP.  I would recommend renaming it toì
  773. something like ZCOLD.CP and then copying the new one into place with aì
  774. command like "PPIP A15:ZC.CP=ZCPR3.COM".  Now just hit control-c to warmì
  775. boot, and the new CPR will be running!
  776.  
  777.      If things did not work out as you intended (and especially if the newì
  778. CPR just crashed the system), you can reboot and reload ZC.COM.  Remember,ì
  779. you did not change the CPR image in ZC.COM yet, and things will be fine soì
  780. long as you don't warm boot.  Before that happens, you should renameì
  781. ZCOLD.CP back to ZC.CP.  Then you can try again.  That is sure a lot easierì
  782. than all the 'sysgening' required to test a new CPR with the manuallyì
  783. installed Z-System.
  784.  
  785.      If all went well, the system is now running just the way you hoped itì
  786. would.  Once you've tested it and are satisfied that it really is workingì
  787. correctly, you can patch the new CPR into ZC.COM so that it will be readyì
  788. immediately after Z-COM loads.  The following commands will do it:
  789.  
  790.     A0:SYS>get 100 zc.com
  791.     A0:SYS>get 200 a15:zc.cp
  792.     A0:SYS>save 2dh zcnew.com
  793.  
  794. As usual, once you have verified that ZCNEW is working, rename it to ZC.COM.  
  795.  
  796.  
  797.                              Summary and Plans
  798.                  -----------------
  799.  
  800.  
  801.      That wraps things up for this time.  You now know how to make enoughì
  802. patches to mold a Z-COM system pretty well to your own tastes.  If you haveì
  803. Z-COM, I hope you will experiment some before the next column appears.  Inì
  804. that column we will really dig into Z-COM and do some wild things.  If youì
  805. have any suggestions or questions, please send them along.  My address andì
  806. phone numbers are listed below.
  807.  
  808.      As a little reward for those of you who plowed through this whole pieceì
  809. (or who were taught the trick I was as a freshman in college to read the endì
  810. of a paper or essay before you start at the beginning), here is a littleì
  811. tidbit.  ZCPR version 3.3 is coming very soon.  I already have a nearlyì
  812. complete version of it patched into the Z-COM I worked up for this article. ì
  813. I expect that Z33 will have been released or will be very close to releaseì
  814. by the time this column appears, and I will devote some space to aì
  815. discussion of its new features in the next column.
  816.  
  817.                     Jay Sage
  818. è                    1435 Centre Street
  819.                     Newton Centre, MA 02159
  820.                     voice: 617-965-3552
  821.                     modem: 617-965-7259
  822.