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 / TCJ32.MZG / TCJ32.MAG
Text File  |  2000-06-30  |  49KB  |  922 lines

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