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