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

  1.      As usual, I find myself with the deadline for this TCJ column fastì
  2. approaching, wondering how two months have passed so quickly.  And, asì
  3. usual, I have far more material that I would like to talk about than I willì
  4. have time to put down on paper (or, should I say, disk).  This column isì
  5. probably going to be shorter than average, just as the previous one was muchì
  6. longer, and some of the promised discussions will be deferred still further. ì
  7. Given the reasons, you will be understanding I hope: Joe Wright and I are inì
  8. the process of putting the final touches on the new releases of ZCOM andì
  9. ZCPR34!  By the time you read this, they will definitely be available.  Evenì
  10. if you usually find my columns a bit too technical for your tastes, I hopeì
  11. you will read on as I describe these two exciting developments.
  12.  
  13.      I will not describe it here this time, but Bridger Mitchell has veryì
  14. nearly completed code similar to NZCOM that will run on CP/M-Plus systems. ì
  15. At last people with newer CP/M machines for which CP/M 2.2 is not availableì
  16. will also be able to run Z System.  And they will be able to do it whileì
  17. retaining almost all of the good features of CP/M-Plus!
  18.  
  19.  
  20.                                 The New ZCOM
  21.  
  22.      Two issues ago (TCJ #30) I described the status of the nascent NZCOM. ì
  23. Things have developed considerably since then, and I can now provide someì
  24. specific details.
  25.  
  26.      First some philosophical comments.  This may sound rather strong, butì
  27. Joe and I both firmly believe that NZCOM is one of the most exciting andì
  28. remarkable developments in the history of microcomputer operating systems. ì
  29. With all the computers we have had experience with, the operating system hasì
  30. been a static entity.  You 'boot' up the computer, and there you have theì
  31. operating system, fixed and immutable.  Few computers offer more than oneì
  32. operating system.  With those that do, the only way you can get a differentì
  33. operating system is to 'reboot', which generally involves inserting a newì
  34. boot diskette and pressing the reset button.  And never do you get to defineì
  35. the characteristics of that operating system.  You just take what theì
  36. manufacturer deigns to let you use.
  37.  
  38.      With NZCOM the operating system becomes a flexible tool just like anì
  39. application program.  You can change operating systems at any time, evenì
  40. right in the middle of a multiple command line sequence.  You can do itì
  41. manually, or alias scripts can do it automatically, in response toì
  42. conditions in the system!  And you can determine which Z System features areì
  43. supported.
  44.  
  45.      You can change the whole operating system or just a part of it.  Wouldì
  46. you like a new command processor?  No problem.  With a simple command, NZCOMì
  47. will load it.  No assembly or configuration required.  One file fits all! ì
  48. That new CCP will continue to run until you load another one.  Want toì
  49. experiment with a new disk operating system (we are playing with severalì
  50. exciting new ones)?  Again, no problem.  NZCOM can load them in a jiffy. ì
  51. This makes for a whole new world of flexibility and adaptability,ì
  52. experimentation and education.
  53.  
  54.      Need more memory to run a big application program?  Fine.  Just load aì
  55. small operating system while that application is running.  When it isì
  56. finished, go back to the big system with bells and whistles like namedì
  57. directories, lots of resident commands, or special input/output facilitiesì
  58. (such as keyboard redefiners or redirection of screen or printer output toì
  59. disk).
  60.  
  61.      Until you try this system, it is hard to imagine how easy it is to doì
  62. these things.  Gone are the days of taking source code (no source code isì
  63. needed), editing configuration files (you don't need an editor), assemblingì
  64. (you don't need an assembler), and patching (you don't have to know how toì
  65. use the arcane SYSGEN and DDT).  Simple REL files for a particular moduleì
  66. can be used by anyone on any system.  Of course, if you want to createì
  67. custom modules of your own special design, you can still do it, but this isì
  68. no longer required, as it used to be.  Hackers can hack, but users canì
  69. simply use!
  70.  
  71.      Joe and I are really hoping that NZCOM will open the world of Z Systemì
  72. to the general community, to those who have no interest in learning toì
  73. assemble their own operating system or do not have the tools or skills.  Ifì
  74. you have been at all intrigued by the Z System (how could you not haveì
  75. been?), now is your chance to experiment.
  76.  
  77.      Getting NZCOM running is basically a two-step process, with each stepì
  78. remarkably easy to perform.  First you define the system or systems youì
  79. want.  This is done with the program MKNZC (MaKe NZ-Com).  Then you load theì
  80. Z System you want using the program NZCOM.  The details are explained below. ì
  81. Some comments of interest to the technically inclined are enclosed inì
  82. brackets.  Feel free to skip over them.
  83.  
  84.  
  85. Defining NZCOM Systems
  86.  
  87.      Here is how a person with a stock CP/M computer would go about gettingì
  88. NZCOM going.  [First technical aside: Ironically, those of us who, withì
  89. great skill and hard work, created manually installed Z Systems have a muchì
  90. harder job ahead of us.  To use NZCOM effectively, we must first strip outì
  91. all the ZCPR3 code in our fancy BIOSs and get back to a lean, Z-less system. ì
  92. I just spent the good part of an evening doing that for my BigBoard Iì
  93. computer (though, to be fair to my programming expertise, I should add thatì
  94. the hardest part was finding where I had stashed the BIOS source code).] ì
  95. For the discussion that follows, we will assume that the files in the NZCOMì
  96. package have been copied onto a working disk in drive A.
  97.  
  98.      As we said earlier, the first step is to use MKNZC, an easy menu-drivenì
  99. program, to specify the characteristics of our Z Systems.  Its output is aì
  100. descriptor file that is used later to load the system.  What if you don'tì
  101. know enough yet about the Z System to make those choices?  Again, noì
  102. problem.  There is a standard (or, in computer language, 'default') systemì
  103. defined for you already, and we will start by making it.  We do that byì
  104. entering the command line
  105.  
  106.     A>mknzc nzcom
  107.  
  108. This will bring up a menu screen like the one shown in Fig. 1.  The onlyì
  109. difference on your system will be in the actual addresses for the modules,ì
  110. since they vary from computer to computer.  Press the 'S' key to save theì
  111. configuration.  MKNZC displays a message to the effect that it is writingì
  112. out the file NZCOM.NZC.
  113.  
  114.      [Technical aside: Files of type NZC are NZCOM descriptor files.  Theyì
  115. are simple text files, as shown in Fig. 2.  For those of you who write yourì
  116. own assembly language programs, you may notice a strong similarity to theì
  117. symbol or SYM file produced by an assembler or linker (yep, identical).  Theì
  118. symbols in this file define all the necessary parameters of the system to beì
  119. created.]
  120.  
  121.      From the values in Fig. 1, you can see that the default Z System offersì
  122. every feature available.  When this system is running later, the TPAì
  123. (transient program area, the memory available for the application programsì
  124. that do your real work) will be 49.0k bytes.  This value, of course, is forì
  125. my computer; as they say, "yours may vary."  A 'k' or kilobyte is actuallyì
  126. 1024 bytes, so this is really 50,176 bytes or characters.  The original CP/Mì
  127. system, by the way, had a TPA of 54.25k bytes, so we are paying a cost ofì
  128. 5.25k bytes for this spare-no-expense Z System.  As luxurious and opulent asì
  129. this system is, it still leaves plenty of TPA for most application programs.
  130.  
  131.      Sometimes, however, we have an application program that is reallyì
  132. hungry for memory.  Database managers, spread sheets, and C compilers oftenì
  133. fall into this category.  So does the new WordStar Release 4.  We will nowì
  134. use MKNZC to define a minimum Z System for when we run those applications. ì
  135. To give this version the name MINIMUM, enter the command
  136.  
  137.     A>mknzc minimum
  138.  
  139. When the menu comes up, press key '4'.  You will be asked to define theì
  140. number of records (128-byte blocks) to allocate to the input/output packageì
  141. or IOP.  Enter '0' and press return.  Similarly reduce to zero theì
  142. allocations for the resident command package (RCP), flow command packageì
  143. (FCP), and named directories register (NDR).  You will be left with theì
  144. screen shown in Fig. 3.  Press the 'S' key to save the definition of thisì
  145. minimal Z System in the descriptor file MINIMUM.NZC [shown in Fig. 4 for theì
  146. technically inclined].
  147.  
  148.      Notice that the TPA has grown to 53.25k, only 1k less than the originalì
  149. miserable CP/M system.  Even with this meagre Z System, costing only 1k ofì
  150. TPA, you get the following features (and more):
  151.  
  152.     multiple commands on a line
  153.     the alias facility that provides automatic command sequence
  154.         generation
  155.     automatic, user-defined search path for COM files
  156.     extended command processing (ARUNZ, described in TCJ #31,
  157.         for example)
  158.     error handling that tells you what's wrong with a bad command
  159.         and allows you to correct it
  160.     shells (menu systems, command history shell for saving and
  161.         recalling old commands, file-maintenance shells, etc.)
  162.     terminal-independent full-screen operation via Unix-like
  163.         TCAP (terminal capabilities descriptor)
  164.  
  165.      These are only two of a wide variety of possible Z Systems.  As youì
  166. gain experience with NZCOM, you can fine tune the definitions to meet all ofì
  167. your needs.  For my BigBoard I computer, I have defined four systems.  Twoì
  168. of them, called FULL and TINY, have the features shown in the two examplesì
  169. here.  A third one is called SMALL.  Not quite as diminutive as TINY, itì
  170. sacrifices an additional 0.5k of TPA to retain the flow command packageì
  171. (FCP), which is so valuable in providing high levels of command automation. ì
  172. Even my voracious application programs can usually get by under this system.
  173.  
  174.      Finally, I have a system called NORMAL, which, as the name implies, isì
  175. the one I use most of the time.  It is the same as FULL but without an IOP. ì
  176. The most common use for an IOP is to run keyboard redefiners like NuKey. ì
  177. Most people like this feature, but splendid as NuKey is, for some reason myì
  178. style does not find much use for keyboard macros (I've become a ratherì
  179. skillful typist and can generally type faster than I can think of moving myì
  180. finger to a special key), so I generally omit the IOP and gain 1.5k of TPA.
  181.  
  182.  
  183. Loading the NZCOM Systems
  184.  
  185.      Having defined the systems above, we can now fire them up even moreì
  186. easily.  For the default NZCOM system, just enter the following simpleì
  187. command:
  188.  
  189.     A>nzcom
  190.  
  191. With no argument after the command name, NZCOM will load the system definedì
  192. with the name NZCOM.  As it does this, you will see a signon message on theì
  193. screen, followed by a series of dots, each one indicating that anotherì
  194. module has been loaded.  [Technical aside:  If you want to see moreì
  195. precisely what is going on, just add the option "/v" to the command toì
  196. select verbose mode.  You will then get a screen display something like thatì
  197. shown in Fig. 5.  I'll have more to say about what all this means a littleì
  198. later.]
  199.  
  200.      After NZCOM starts running, it executes a program called START.COM. ì
  201. This is usually an alias command, a program that simply passes another moreì
  202. complex command line on to the command processor.  I will not explain theì
  203. details of START here, but after it finishes, Z System will be up andì
  204. running, waiting for your commands.
  205.  
  206.  
  207. How NZCOM Works
  208.  
  209.      This section is for the technically inclined, so if that's not you,ì
  210. pretend there are square brackets around this whole section and skip aheadì
  211. to the next section.  Here we are going to explain what some of thoseì
  212. verbose-mode messages mean and what NZCOM is doing to create the system onì
  213. the fly.
  214.  
  215.      First NZCOM loads the descriptor file into memory.  Among other things,ì
  216. this file has the information about which system modules to load and to whatì
  217. starting addresses.  The first module loaded is the command processor.  Itì
  218. is loaded from the file NZCPR.REL, which has the code for the commandì
  219. processor (ZCPR34) in so-called relocatable form.
  220.  
  221.      There is some very interesting assembly/linkage razzle-dazzle that goesì
  222. on here.  With the REL files one usually plays with, only the run-timeì
  223. execution address of the code is unknown at assembly time and must beì
  224. resolved by the linker.  Things are much trickier here.  When the commandì
  225. processor code was assembled, not only was its own run-time starting addressì
  226. unknown, but the addresses of various other system components, such as theì
  227. message buffer and multiple command line, to which it refers in countlessì
  228. places, are also unknown.  Since there is no fixed relationship between theì
  229. addresses of the CCP and these other modules, there is no way to define theì
  230. addresses using equates in the code.
  231.  
  232.      Put another way, when NZCOM converts NZCPR.REL into actual object code,ì
  233. it must resolve not only the calls and jumps and data loads that refer toì
  234. other locations in the command processor but also those that refer to theì
  235. other system modules.  Fortunately, advanced assemblers and linkers --ì
  236. including those from SLR Systems and a ZAS follow-on under development byì
  237. Echelon -- already have a mechanism to handle this problem.  It was Bridgerì
  238. Mitchell who recognized how this mechanism, called named common, couldì
  239. accomplish what was needed here.
  240.  
  241.      When code with symbols in named common is assembled, the correspondingì
  242. bytes in the resulting REL file are marked not only for relocation but forì
  243. relocation with respect to a specific common block.  The SLR assemblersì
  244. support up to 12 named common blocks.  NZCOM contains very sophisticatedì
  245. linking code that resolves the references to data items in the commonì
  246. blocks, the addresses of which it gets, naturally, from the NZC descriptorì
  247. file.
  248.  
  249.      Fig. 6 shows a partial listing of the file NZCMN.LIB, which isì
  250. referenced in a MACLIB statement in each module assembled for use by NZCOM. ì
  251. Seven named common blocks are defined: _BIOS_, _ENV_, _SSTK_, _MSG_, _FCB_,ì
  252. _MCL_, and _XSTK_ for the CBIOS, environment descriptor, shell stack,ì
  253. message buffer, external file control block, multiple command line buffer,ì
  254. and external stack, respectively.  Note that no common blocks are definedì
  255. for the RCP, FCP, or NDR.  References to these package must be madeì
  256. indirectly at run time, using data obtained from the environment descriptorì
  257. in memory.
  258.  
  259.      How does the NZCOM loader figure out that the file NZCPR.REL is theì
  260. command processor?  You might think that it uses the name of the file, but,ì
  261. in fact even if you had a copy of it called MYNEWCP.REL, NZCOM would be ableì
  262. to load it just as well.  The answer is that the source code contains theì
  263. directive
  264.  
  265.         NAME ('CCP')
  266.  
  267. which gives the REL file an internal module name.  It is this name thatì
  268. NZCOM uses to determine what kind of module the code represents.
  269.  
  270.      After the command processor is loaded, the other modules are loaded inì
  271. succession in similar fashion, except for two.  The named directory fileì
  272. NZCOM.NDR is a file that you can make or change with the standard utilityì
  273. programs MKDIR or EDITNDR/SAVENDR.  There is nothing in an NDR file thatì
  274. requires relocation at all.  The same is true for the Z3T terminalì
  275. descriptor (TCAP) file.  It can be created using the TCSELECT utility.
  276.  
  277.      When all the loading is done, a copy of the command processor objectì
  278. code is written out to a file called NZCOM.CCP.  This file is used forì
  279. subsequent warm boots, since we obviously cannot warm boot from what is onì
  280. the system tracks of the disk (the Digital Research command processor isì
  281. still there, after all).  At this point we can resume the non-technicalì
  282. discussion.
  283.  
  284.  
  285. Changing NZCOM Systems
  286.  
  287.      Now that you have Z System running, you can start to work with it andì
  288. learn about it.  I am not going to discuss Z System in general here; theì
  289. subject is much too extensive.  One thing you can do is to get out your backì
  290. issues of TCJ and experiment with the programs described there.  Another isì
  291. to buy the "Z System User Guide" published by Echelon.  That book describesì
  292. the Z System from a less technical point of view than Richard Conn's "ZCPR3,ì
  293. The Manual," also published by Echelon.
  294.  
  295.      What I would like to discuss now is some of the ways you can use the dynamic capabilities of NZCOM.  First we will describe how you change theì
  296. entire operating system.  For these examples we will assume that you haveì
  297. been doing work in various directory areas on your system and that you haveì
  298. set up named directories.  Let's say you are in your dBase II area now. ì
  299. Since you know that dBase II needs a lot of memory to run efficiently (orì
  300. should I say 'tolerably,' since it never runs efficiently!) and sinceì
  301. (unlike WordStar 4, for example) it cannot make use of any Z System featuresì
  302. anyway, you want to load the minimum system we created earlier.  You canì
  303. probably guess what the command is:
  304.  
  305.     B2:DBASE>nzcom minimum
  306.  
  307.      [More technical stuff: Fig. 7 shows the screen display you would getì
  308. with the "/v" verbose option on this command.]   For the minimum systemì
  309. NZCOM loads only a command processor, disk operating system, and virtualì
  310. BIOS.  The other system segments disappear.  This includes the NDR or namedì
  311. directory register, so the prompt changes to
  312.  
  313.     B2>
  314.  
  315. The START alias does not run this time.  It runs only when NZCOM is loadedì
  316. from a non-NZCOM system (such as CP/M).
  317.  
  318.      In general, when loading a new version of the operating system fromì
  319. another that is currently running, NZCOM loads only the modules that must beì
  320. loaded, either (1) because they did not exist before or (2) because they areì
  321. now at a different address or have a different size.  For example, when Iì
  322. load my FULL system from the NORMAL system to add an IOP, only the CCP, DOS,ì
  323. BIOS, and IOP are loaded, since the RCP, FCP, and NDR are in the same placeì
  324. as before and have the same size.  When modules do have to be loaded, filesì
  325. with the default names shown in Fig. 5 are used.  Later we will discuss howì
  326. you can load modules with other names.
  327.  
  328.      There are a number of system modules that never change in the presentì
  329. version of NZCOM.  (Yes, like the famous Al Jolson lines, you ain't seenì
  330. nothin' yet!)  These include the environment descriptor, message buffer,ì
  331. shell stack, path, wheel byte, and multiple command line buffer.  With theì
  332. exception of module addresses in the environment descriptor, data in theseì
  333. fixed system modules remain unaffected.  This means that if you had selectedì
  334. an error handler, for example, or a shell such as a command history shell,ì
  335. they will still be in effect after a change of system.
  336.  
  337.      Because the multiple command line buffer is preserved through the loadì
  338. of a new system, you can include NZCOM commands as part of multiple commandì
  339. sequences, alias scripts, and shell (MENU, VMENU, or ZFILER) macros.  Thus,ì
  340. for example, you could have entered the command
  341.  
  342.     B2:DBASE>nzcom minimum;dbase etc.
  343.  
  344. In this case the operating system would have changed, and then DBASE wouldì
  345. have started running.  I will not go into the technical details here, butì
  346. there are ways to write an alias script, which might be called DB, thatì
  347. would check to see if the minimum system was already running and, if not,ì
  348. automatically load it before invoking DBASE.
  349.  
  350.      Nothing says the operating system can change only once in the course ofì
  351. a multiple command line.  You might have alias scripts that change to aì
  352. minimum system, run a specific command, and then reload the normal systemì
  353. again.  There is a time penalty associated with this (though very little ifì
  354. you have the NZCOM files on a RAM disk), but the result is that theì
  355. application program sees a big TPA while it is running, but you always see aì
  356. nice, full-featured Z System.
  357.  
  358.      NZCOM does not even insist that you stay in Z System.  On the contrary. ì
  359. On a cold load from CP/M it will build (if it does not exist already) aì
  360. program called NZCPM that, when run from Z System, will restore the originalì
  361. CP/M system.
  362.  
  363.      [Technical aside: Even if you need absolutely every available byte ofì
  364. TPA, you can still automate the process.  You can use the submit facility toì
  365. run a batch job that exits from Z System entirely, runs an application underì
  366. plain CP/M, and then returns to Z System.  You do have to observe someì
  367. precautions.  For example, you have to make sure that all command lines inì
  368. the batch file that will execute while Z System is not in effect are validì
  369. CP/M commands.  Once the batch script has reloaded Z System using the NZCOMì
  370. command, it can resume using appropriate Z System commands, includingì
  371. multiple commands on a line.
  372.  
  373.      Another factor to bear in mind is that NZCPM returns you to CP/M inì
  374. drive A user 0 no matter where you were when it executed.  Since ZCPR3ì
  375. (starting with version 3.3) writes its submit file to directory A0 ratherì
  376. than the current directory, there is no problem with continuing operation ofì
  377. the batch file under CP/M.  However, when you reload NZCOM (it will be aì
  378. cold load, including execution of START), you will not automatically be backì
  379. in your original directory.  End aside.]
  380.  
  381.  
  382. Changing Parts of the System
  383.  
  384.      The NZCOM command is not limited to loading whole new operatingì
  385. systems; with a slightly different syntax it can also load individual systemì
  386. modules, rather like the LDR program in a manually installed Z System. ì
  387. There are two important differences, however.
  388.  
  389.      The first is that NZCOM loads code modules (IOP, RCP, and FCP) from RELì
  390. files rather than from absolute files such as SYS.FCP or DEBUG.RCP. ì
  391. Absolute files can still be loaded using LDR, but this is undesirable underì
  392. NZCOM, since the addresses of the modules may change as different systemsì
  393. are loaded.  NZCOM has the advantage of using a single REL file no matterì
  394. which system it is being loaded into.  In the future, RCPs, FCPs, and IOPsì
  395. will be distributed in REL form instead of (or in addition to) source codeì
  396. form.  The REL file is much smaller and can be used without knowing how toì
  397. assemble the code.
  398.  
  399.      The second difference is that NZCOM can load command processors andì
  400. disk operating systems as well.  This makes it very easy to change versionsì
  401. of the command processor (with or without security or named directory orì
  402. submit support, for example) or to experiment with alternative DOSs, such asì
  403. Z80DOS or P2DOS.  This will be a real boon to the development of newì
  404. operating system components, since one can test new versions so easily andì
  405. quickly.
  406.  
  407.      For convenience, NZCOM can also load named directory files (of typeì
  408. NDR) and terminal descriptor files (of type Z3T).  This is so that you doì
  409. not have to have LDR.COM on your disk.  On an NZCOM system, LDR is aì
  410. dangerous command, since it does not have safeguards against loadingì
  411. absolute system components to addresses for which they were not assembled. ì
  412. With an NZCOM system, you should remove LDR.COM from your disk.
  413.  
  414.  
  415. Other NZCOM Features
  416.  
  417.      There are many more things that could be said about NZCOM that I willì
  418. save for another time.  There is just one more that I want to mention now,ì
  419. and that is the extra "Custom Patch Area" that can be defined with MKNZCì
  420. (see Fig. 1).  This option in MKNZC allows one to establish an area inì
  421. protected memory just below the CBIOS (custom BIOS or real BIOS).  This areaì
  422. can be used by various operating system extensions that one wants toì
  423. preserve from one NZCOM system to another.
  424.  
  425.      Because of the techniques it uses for patching the Z System onto CP/M,ì
  426. NZCOM will not work when a resident system extension (RSX) is present. ì
  427. Thus, for example, you cannot run NZCOM from inside a ZEX script or ifì
  428. DateStamper or BYE is active in low memory (if they are loaded above theì
  429. CBIOS, there is no problem).  I am presently using the patch area forì
  430. DateStamper.  With NZCOM you can effectively have an above-BIOS version ofì
  431. DateStamper without having to move your BIOS down.
  432.  
  433.      I am also planning to experiment with putting BYE in the custom patchì
  434. area.  I think this can be made to work, and it would permit NZCOM to beì
  435. used on my Z-Node (and I mean used actively -- so that the NZCOM system canì
  436. be changed even from a remote terminal!).
  437.  
  438.      There are special facilities in NZCOM that I do not have the energy toì
  439. explain now whereby information about a currently running system can beì
  440. extracted before the new system has been loaded and used to initialize theì
  441. new system just before NZCOM turns over control to it.  This allows an RSX'sì
  442. hooks into the operating system to be maintained.
  443.  
  444.  
  445.                              ZCPR Version 3.4
  446.  
  447.      Now let's turn to the subject of ZCPR version 3.4, which will beì
  448. released along with NZCOM.  Z34, as I will refer to it, is much more anì
  449. evolutionary step from Z33 than Z33 was from Z30.  There are four newì
  450. features worth pointing out.
  451.  
  452.  
  453. Type-4 Programs
  454.  
  455.      The most important and exciting enhancement is the introduction of whatì
  456. is called the type-4 program.
  457.  
  458.      With Z33 I added support for a new kind of program to run under ZCPR3. ì
  459. Programs designed to take advantage of the special features of the Z Systemì
  460. have at the beginning of the code a special block of data called the Z3ENVì
  461. header.  This header identifies the program as a ZCPR3 program and containsì
  462. the address of the ZCPR3 environment descriptor, where all the informationì
  463. necessary to find out about the Z System facilities is available.  It alsoì
  464. contains a type byte.  Conventional Z System programs were of type 1. ì
  465. (Type-2 programs are similar but actually have the entire environmentì
  466. desciptor in the header.  Programs of this type are extremely rare.  In someì
  467. senses they are a holdover from ZCPR2 and now obsolete.)
  468.  
  469.      For the new type-3 program I added an additional datum in the Z3ENVì
  470. header: the starting address for which the code had been assembled orì
  471. linked.  The command processor automatically loads the file to that addressì
  472. before transferring control to it.
  473.  
  474.      Type-3 programs are usually linked to run in high memory (for example,ì
  475. 8000H or 32K decimal) where they do not interfere with most data or code inì
  476. the TPA.  Programs that run as extensions of the operating system (viz.ì
  477. history shells, extended command processors, transient IF processor) or asì
  478. the equivalents of resident programs (viz. ERA.COM, REN.COM, SAVE.COM) areì
  479. particularly suitable for implementation as type-3 programs.  One cannotì
  480. always foresee when these programs will be invoked, and it is nice if theì
  481. contents of memory at the bottom of the TPA are not affected when they doì
  482. run.
  483.  
  484.      With type-3 programs one must choose in advance the address at whichì
  485. they will run.  If the address is too high, there may not be enough room forì
  486. them to load, and if too low, they are more likely to interfere withì
  487. valuable TPA contents.  In most situations it would clearly be preferable ifì
  488. the program could be loaded automatically as high as possible in memory.  Iì
  489. thought of this from the beginning but compromised on the type-3 constructì
  490. because it was so easy to code.
  491.  
  492.      Joe Wright was not satisfied with this compromise.  He soon wrote anì
  493. initial version of the type-4 program, which does relocate automatically toì
  494. the top of memory.  With a lot of cooperation between us, we have honed itì
  495. to the point where it functions very nicely and does not add very much codeì
  496. to the command processor.
  497.  
  498.      Because type-3 programs run at a fixed address, albeit not necessarilyì
  499. 100H, they can be assembled and linked in the usual fashion, and the programì
  500. files contain actual binary object code.  Type-4 programs, on the otherì
  501. hand, must be relocatable by the command processor at run time.  Thus objectì
  502. code alone is not sufficient.
  503.  
  504.      One possibility would be to use a REL file directly.  This would haveì
  505. been very convenient, but the code required to load a REL file is far tooì
  506. complex to include in a command processor running in a 64K memory segment. ì
  507. There is a less familiar relocatable type file known as a PRL (Pageì
  508. ReLocatable) file that, because it restricts the relocation to pageì
  509. boundaries (and other reasons), is much easier to relocate.
  510.  
  511.      A PRL file consists of three parts.  The middle part is a standard codeì
  512. image for execution at 100H.  After this comes what is called a bit map,ì
  513. where, for each byte in the code image, there is a bit of 0 or 1 to tellì
  514. whether that byte must be offset for execution at a different page.  The bitì
  515. map is one eighth the length of the code image.  Finally, one page (256ì
  516. bytes) at the beginning of the file serves as a header.  This headerì
  517. contains information about the size of the program so that the code thatì
  518. loads it can figure out where the object code ends and the bit map begins.
  519.  
  520.      In the type-4 program, this header is extended to include the codeì
  521. necessary (1) to calculate the highest address in memory at which theì
  522. program can be loaded and (2) to perform the code relocation to that addressì
  523. using the bit map.  The way this is accomplished is somewhat intricate.
  524.  
  525.      The command processor loads the first record of the type-4 file intoì
  526. the temporary buffer at 80H as usual to determine the program type.  If itì
  527. is type 4, the CCP then calls the code in the header.  That code calculatesì
  528. the load address and then (this clever idea was Joe's) calls the commandì
  529. processor back to load the program code and bit map into memory at theì
  530. proper address.  When this call is complete and control returns to theì
  531. header code, it then performs the relocation of the code image at theì
  532. execution address in memory.  Only then is control returned to the commandì
  533. processor for initialization and execution of the program.
  534.  
  535.      The result of this tricky scheme is that most of the type-4 supportì
  536. code that would otherwise have been required in the command processor is inì
  537. the header instead (this was my contribution to the type-4 concept).  Sinceì
  538. a PRL file has a two record header anyway (almost all of which is otherwiseì
  539. empty), you get to add this code for free.
  540.  
  541.      Joe pointed out to me some dangers with my type-3 construct.  Suppose aì
  542. type-3 program designed to run at 8000H is somehow loaded to 100H instead. ì
  543. Any attempt to execute it is likely to have less than desirableì
  544. consequences, to put it mildly.  This was not a serious problem with aì
  545. normal (at the time) ZCPR33 system.  Since the command processor wouldì
  546. automatically load the type-3 program to the correct address, it took someì
  547. deliberate action by the user to create the dangerous situation described. ì
  548. Of course, the poor fellow still running ZCPR30 who decided to try out aì
  549. type-3 program...
  550.  
  551.      However, now that NZCOM is here, the user may very well decide to dropì
  552. back into CP/M from Z System to perform some tasks.  In this situation, aì
  553. type-3 program is a live weapon, just waiting to blow up the system.  Theì
  554. type-4 program poses a similar danger.
  555.  
  556.      We have come up with two defense strategies.  One can be implemented inì
  557. the program itself.  There is code (TYP3HDR1.Z80) that can be placed at theì
  558. beginning of a type-3 program (based on ideas conceived independently by Bobì
  559. Freed and Joe Wright) that will verify that the code is running at theì
  560. proper address.  This part of the code is, as it must be, addressì
  561. independent (it uses only relative jumps).  If the load address is found toì
  562. be wrong, a warning message is displayed and control is returned to theì
  563. command processor before any damage can be done.  This is the friendlierì
  564. method, but it makes the programs longer.
  565.  
  566.      The second defense method does not impose any overhead on the programì
  567. code.  It is easier to use than the other method, and it can generally beì
  568. patched into existing type-3 programs in object form.  It can also beì
  569. applied with type-4 programs, for which the first method cannot be usedì
  570. (type-4 files begin with a relocation header and not with program code, andì
  571. the system must be prevented from trying to execute the header when theì
  572. program is invoked under CP/M).
  573.  
  574.      With this method, one places a byte of C7H, the RST 0 instructionì
  575. opcode, at the beginning of the file.  Execution of this instruction causesì
  576. a call to address 0, which induces a warm boot.  This behavior may beì
  577. puzzling to the user, but at least it does no damage.  How, then, will suchì
  578. a program ever execute?  The answer is that ZCPR34 checks the first byte ofì
  579. a type-3 program to see if it is a C7H.  If it is, the command processorì
  580. replaces it with a C3H, the JP instruction opcode.  To take advantage ofì
  581. this method, the program code must begin with a "JP START" instruction inì
  582. which the JP is replaced by RST 0 (note: you cannot use JR START instead). ì
  583. The proper assembly language source code is illustrated in Fig. 8.  Noteì
  584. that the replacement of the RST 0 by a JP is not required with a type-4ì
  585. program since the header (which is where this construct appears) is neverì
  586. intended to be executed as a standard program, even under Z34.
  587.  
  588.  
  589. The Extended Environment Descriptor and the Drive Vector
  590.  
  591.      The definition of the ZCPR3 environment descriptor has been modifiedì
  592. and extended.  I will not go into all the details here, but I will describeì
  593. the main changes.
  594.  
  595.      First, to make some space available for additional importantì
  596. information, the extended ENV eliminates definitions for all but one consoleì
  597. and one printer.  Eventually there will be a tool (utility program) thatì
  598. allows interactive or command-line redefinition of the characteristics ofì
  599. these single devices so that you will actually have more rather than lessì
  600. flexibility.
  601.  
  602.      The extended ENV will now contain the addresses and sizes in records ofì
  603. the CCP, DOS, and BIOS (actually, the size of the BIOS is not included). ì
  604. This information has been added to deal with problems in some specialì
  605. operating system versions where the CCP and/or DOS do not have theirì
  606. standard sizes of 16 and 28 records respectively, such as in the Echelonì
  607. Hyperspace DOS for the DT-42 computer.  Future versions of NZCOM, which willì
  608. support variable CCP, DOS, and BIOS modules, will also need this.
  609.  
  610.      Finally, a long needed feature has at last been implemented; a driveì
  611. vector.  The maximum-drive value in the ENV was not adequate in a systemì
  612. with non-contiguous drives (A, B, and F, for example).  Now you can tell theì
  613. system exactly which drives you have on the system, and the commandì
  614. processor will do its best to prevent references to nonexistent drives.
  615.  
  616.  
  617. Ever More Sensible Named Directory Security
  618.  
  619.      With Z33 I made it possible to refer by drive/user (DU) to directoriesì
  620. beyond the range specified by the maximum drive and maximum user values inì
  621. the environment provided the directory area had a name with no password.  Itì
  622. seemed only reasonable that if a user could access the drive by name, heì
  623. should be allowed to access it by its equivalent DU as well.
  624.  
  625.      The converse situation, however, was not handled according to similarì
  626. logic.  Suppose the maximum user was 7 but there was a password-protectedì
  627. named directory for user 6.  Under Z33 one had the anomalous situation thatì
  628. the user could refer freely to the directory using the DU form but would beì
  629. pestered for the password if he used the named-directory (DIR) form.  Thisì
  630. just didn't seem reasonable, and Z34 has corrected this.
  631.  
  632.  
  633. Extended ECP Interface
  634.  
  635.      With Z34 I have added an additional option along the lines of BADDUECP. ì
  636. The BADDUECP option allows directory-change commands of the form NAME: orì
  637. DU: that refer to illegal directories to be passed on to the extendedì
  638. command processor (ECP) instead of directly to the error handler.  On my Z-Node, for example, I use the ARUNZ extended command processor to permitì
  639. references to reasonable facsimiles to the actual directory names to workì
  640. via alias scripts.
  641.  
  642.      With Z33 attempts to execute a command containing an illegal wildcardì
  643. character or with an explicit file type would be flagged as errors andì
  644. passed directly to the error handler.  With Z34 one has the option (via theì
  645. option BADCMDECP) to pass these forms of bad command to the extended commandì
  646. processor as well.
  647.  
  648.      Here are a couple of examples of how this feature can be used with theì
  649. ARUNZ extended command processor.  First, one can enter the following scriptì
  650. into the alias definition file ALIAS.CMD:
  651.  
  652.     ?  help $*
  653.  
  654. Now when a user enters the command "?", he will get the help system insteadì
  655. of an error message telling him that he entered a bad command.
  656.  
  657.      You can also use this facility to allow further shorthand commands. ì
  658. With the script definition
  659.  
  660.     DIM.Z3T   ldr dim.z3t   (or nzcom dim.z3t)
  661.  
  662. Now you can load the dim-video TCAP for your system simply by just enteringì
  663. the name of the TCAP file.  Using wildcard specifiers in the name of theì
  664. alias script, you can make any command with a type of Z3T load theì
  665. corresponding TCAP file.  Similarly, entering the name of a library (forì
  666. example, LBRNAME.LBR) on the command line could automatically invoke VLU onì
  667. that library.  The same concept would allow one to enter the name of aì
  668. source-code file (for example, THISPROG.Z80 or THATPROG.MAC) toì
  669. automatically invoke the appropriate assembler (Z80ASM/ZAS or SLRMAC/M80 forì
  670. these two examples).
  671.  
  672.      This feature opens another whole dimension for experimentation, and Iì
  673. am sure that users will come up with all kinds of new ways to use it. ì
  674. PLEASE NOTE: if this feature is implemented, you cannot use the old versionì
  675. of ARUNZ that I so painstakingly documented in my last column (alas, barelyì
  676. born and already obsolete).  Previous versions of ARUNZ used '?' and '.' forì
  677. special purposes.  Those characters were carefully chosen because they couldì
  678. never appear in command names passed to ARUNZ, but now they can!  Therefore,ì
  679. in version 0.9H of ARUNZ I have changed these characters to '_' (underscore)ì
  680. instead of '?' and ',' (comma) instead of '.'.
  681.  
  682.      That's it for this issue, I'm afraid.  I still didn't get to aì
  683. discussion of defects in the shell coding for WordStar 4 (I hope these willì
  684. be corrected in version 5, which is apparently really in the works at thisì
  685. time).  My discussion of the ZEX in-memory batch processor and theì
  686. improvements I have been making to it will also have to wait still longer.
  687.  
  688. ------------------------------------------------------------------------------
  689.  
  690.     1.*    Command Processor    CCP    BD00        16 Records
  691.     2.*    Disk Operating System    DOS    C500        28 Records
  692.     3.*    NZ-COM Bios        BIO    D300         2 Records
  693.  
  694.     4.    In/Output Processor    IOP    D400        12 Records
  695.     5.    Resident Command Proc    RCP    DA00        16 Records
  696.     6.    Flow Control Processor    FCP    E200         4 Records
  697.     7.    Named Directory Reg    NDR    E400        14 Names
  698.  
  699.     8.*    Environment Descriptor    ENV    E500         2 Records
  700.     9.*    Shell Stack        SHS    E600         4 Entries
  701.  
  702.     P.    Custom Patch Area    PAT    0000         0 Records
  703.         Customer's CBIOS    TOP    E800
  704.  
  705.             Effective TPA size 49.0k
  706.  
  707.     * Items 1, 2, 3, 8 and 9 are not changeable in this version.
  708.  
  709.     Selection: (or <S>ave or <Q>uit) _
  710.  
  711.  
  712. Figure 1.  Screen displayed by the MKNZC program when run under CP/M.  Thisì
  713. is the standard or default system definition.
  714.  
  715. ------------------------------------------------------------------------------
  716.  
  717. E806 CBIOS    0080 ENVTYP    E6F4 EXPATH    0005 EXPATHS    DA00 RCP
  718. 0010 RCPS    D400 IOP    000C IOPS    E200 FCP    0004 FCPS
  719. E400 Z3NDIR    000E Z3NDIRS    E700 Z3CL    00CB Z3CLS    E500 Z3ENV
  720. 0002 Z3ENVS    E600 SHSTK    0004 SHSTKS    0020 SHSIZE    E680 Z3MSG
  721. E6D0 EXTFCB    E7D0 EXTSTK    0000 QUIET    E6FF Z3WHL    0004 SPEED
  722. 0010 MAXDRV    001F MAXUSR    0001 DUOK    0000 CRT    0000 PRT
  723. 0050 COLS    0018 ROWS    0016 LINS    FFFF DRVEC    0000 SPAR1
  724. 0050 PCOL    0042 PROW    003A PLIN    0001 FORM    0066 SPAR2
  725. 0042 SPAR3    003A SPAR4    0001 SPAR5    BD00 CCP    0010 CCPS
  726. C500 DOS    001C DOSS    D300 BIO    0000 PUBDRV    0000 PUBUSR
  727.  
  728. Figure 2.  For the technically inclined, this is a listing of the contentsì
  729. of the NZCOM.NZC system descriptor file produced by MKNZC.
  730.  
  731. ------------------------------------------------------------------------------
  732.  
  733.     1.*    Command Processor    CCP    CE00        16 Records
  734.     2.*    Disk Operating System    DOS    D600        28 Records
  735.     3.*    NZ-COM Bios        BIO    E400         2 Records
  736.  
  737.     4.    In/Output Processor    IOP    0000         0 Records
  738.     5.    Resident Command Proc    RCP    0000         0 Records
  739.     6.    Flow Control Processor    FCP    0000         0 Records
  740.     7.    Named Directory Reg    NDR    0000         0 Names
  741.  
  742.     8.*    Environment Descriptor    ENV    E500         2 Records
  743.     9.*    Shell Stack        SHS    E600         4 Entries
  744.  
  745.     P.    Custom Patch Area    PAT    0000         0 Records
  746.         Customer's CBIOS    TOP    E800
  747.  
  748.             Effective TPA size 53.25k
  749.  
  750.     * Items 1, 2, 3, 8 and 9 are not changeable in this version.
  751.  
  752.     Selection: (or <S>ave or <Q>uit) _
  753.  
  754.  
  755. Figure 3.  Screen displayed by the MKNZC program after eliminating the IOP,ì
  756. RCP, FCP, and NDR modules in order to define a minimal Z System.
  757.  
  758. ------------------------------------------------------------------------------
  759.  
  760. E806 CBIOS    0080 ENVTYP    E6F4 EXPATH    0005 EXPATHS    0000 RCP
  761. 0000 RCPS    0000 IOP    0000 IOPS    0000 FCP    0000 FCPS
  762. 0000 Z3NDIR    0000 Z3NDIRS    E700 Z3CL    00CB Z3CLS    E500 Z3ENV
  763. 0002 Z3ENVS    E600 SHSTK    0004 SHSTKS    0020 SHSIZE    E680 Z3MSG
  764. E6D0 EXTFCB    E7D0 EXTSTK    0000 QUIET    E6FF Z3WHL    0004 SPEED
  765. 0010 MAXDRV    001F MAXUSR    0001 DUOK    0000 CRT    0000 PRT
  766. 0050 COLS    0018 ROWS    0016 LINS    FFFF DRVEC    0000 SPAR1
  767. 0050 PCOL    0042 PROW    003A PLIN    0001 FORM    0066 SPAR2
  768. 0042 SPAR3    003A SPAR4    0001 SPAR5    CE00 CCP    0010 CCPS
  769. D600 DOS    001C DOSS    E400 BIO    0000 PUBDRV    0000 PUBUSR
  770.  
  771. Figure 4.  For the technically inclined, this is a listing of the fileì
  772. MINIMUM.NZC, which describes a minimum-size version of an NZCOM system forì
  773. the computer in Figs. 1 and 2.
  774.  
  775. ------------------------------------------------------------------------------
  776.  
  777.     A>nzcom /v
  778.     NZCOM Ver 2.0 Copyright (C) 1987-88 Alpha Systems Corp. 21 Jan 88
  779.      Input buffer start 1C00
  780.      Read  buffer start 1D00
  781.      Write buffer start 3D00
  782.      Loading A0:NZCOM.NZC
  783.      Loading A0:NZCPR.REL for BD00 at 3D00
  784.      Loading A0:NZDOS.REL for C500 at 4500
  785.      Loading A0:NZBIO.REL for D300 at 5300
  786.      Loading A0:NZIOP.REL for D400 at 5400
  787.      Loading A0:NZRCP.REL for DA00 at 5A00
  788.      Loading A0:NZFCP.REL for E200 at 6200
  789.      Loading A0:NZCOM.NDR for E400 at 6400
  790.      Loading A0:NZCOM.Z3T for E580 at 6580
  791.      Writing A15:NZCOM.CCP
  792.      Booting NZ-COM...
  793.  
  794. Figure 5.  This is the screen display produced by NZCOM as it loads theì
  795. default system definition NZCOM.NZC with the verbose option.
  796.  
  797. ------------------------------------------------------------------------------
  798.  
  799. ; Named COMMON declarations start here
  800. ; For compatibility, these are the same names used by Bridger Mitchell's
  801. ; JetLDR
  802.  
  803.     common    /_BIOS_/
  804. cbios:                ; Customer's bios address
  805.  
  806.     common    /_ENV_/
  807. z3env:                ; Z3 Environment descriptor
  808. z3envs    equ    2        ; Size (records)
  809. rcp    equ    z3env+12
  810. rcps    equ    yes        ; Used as existence test, not size
  811. fcp    equ    z3env+18
  812. fcps    equ    yes        ; Used as existence test, not size
  813. z3ndir    equ    z3env+21
  814. z3ndirs    equ    yes        ; Used as existence test, not size
  815.  
  816. drvec    equ    z3env+52    ; Valid drive vector
  817.  
  818. ccp    equ    z3env+63    ; CCP entry
  819. ccps    equ    z3env+65    ; Size
  820.  
  821. dos    equ    z3env+66    ; DOS entry (+6)
  822. doss    equ    z3env+68    ; Size
  823.  
  824. bio    equ    z3env+69    ; BIO entry
  825.  
  826.     common    /_SSTK_/
  827. shstk:                ; Top of Shell stack
  828. shstks    equ    4        ; 4 entries
  829. shsize    equ    32        ; 32 bytes each
  830.  
  831.     common    /_MSG_/
  832. z3msg:                ; Message buffer
  833. z3msgs    equ    80        ; 80 bytes long
  834.  
  835.     common    /_FCB_/
  836. extfcb:                ; External file control block
  837. extfcbs    equ    36        ; 36 bytes long
  838. expath    equ    extfcb+extfcbs    ; External path
  839. expaths    equ    5        ; 5 elements
  840. z3whl    equ    expath+(expaths*2)+1 ; The wheel byte
  841. z3whls    equ    1        ; 1 byte
  842.  
  843.     common    /_MCL_/
  844. z3cl:                ; Multiple command line
  845. z3cls    equ    203        ; Maximum command length
  846. nzpat    equ    z3cl+256    ; Potential User patch area
  847.  
  848.     common    /_XSTK_/
  849. extstk:                ; External stack
  850. extstks    equ    48        ; Size (bytes)
  851.  
  852.     cseg            ; Select Code Segment
  853.  
  854. ; End of NZCMN.LIB
  855.  
  856. Figure 6.  This is a partial listing of the file NZCMN.LIB, which definesì
  857. the named common blocks used during assembly of modules for use by NZCOM.
  858.  
  859. ------------------------------------------------------------------------------
  860.  
  861.     B2:DBASE>nzcom minimum /v
  862.     NZCOM Ver 2.0 Copyright (C) 1987-88 Alpha Systems Corp. 21 Jan 88
  863.      Input buffer start 1C00
  864.      Read  buffer start 1D00
  865.      Write buffer start 3D00
  866.      Loading A0:MINIMUM.NZC
  867.      Loading A0:NZCPR.REL for CE00 at 3D00
  868.      Loading A0:NZDOS.REL for D600 at 4500
  869.      Loading A0:NZBIO.REL for E400 at 5300
  870.      Loading A0:NZCOM.Z3T for E580 at 5480
  871.      Writing A15:NZCOM.CCP
  872.      Booting NZ-COM...
  873.  
  874. Figure 7.  This is the screen display when NZCOM loads the minimum systemì
  875. from a running default system.
  876.  
  877. ------------------------------------------------------------------------------
  878.  
  879.     ENTRY:                ; Beginning of program
  880.         DB    0C7H        ; RST 0 opcode, will become JP
  881.         DW    START
  882.         DB    'Z3ENV'        ; ZCPR3 program ID
  883.         DB    3        ; Type 3
  884.     ENVADR:    DW    0        ; ENV address filled in by Z34
  885.         DW    ENTRY        ; Execution address
  886.     START:                ; Beginning of main program
  887.  
  888. Figure 8.  Form of the Z3ENV header code in a protected type-3 program.  Anì
  889. attempt to execute this code under CP/M will result in a warm boot.
  890.