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 / JSAGE / ZSUS / TCJ / TCJ26.MAG < prev    next >
Text File  |  2000-06-30  |  26KB  |  450 lines

  1.                                Z-System Corne≥ (c)
  2.                                  by Jay Sage
  3.                         The Computer Journal, Issue 26
  4.                           Reproduced with permission
  5.                            of author and publisher
  6.  
  7.  
  8.  
  9. This is the text of my second article in The Computer Journal.   Please note
  10. that  there  is an error in the discussion of the operation of flow  control
  11. commands  with  colons in the command.   The third article,  which  has  now
  12. appeared, discusses the error and sets the record straight.
  13.  
  14.      In my last column I promised that this time I would discuss some  ideas
  15. for new Z-System programs and program enhancements.   Before turning to that
  16. subject, however, I would like to address another issue.
  17.  
  18.  
  19.                        ZCPR3 on a Floppy-Only System
  20.  
  21.      Many  people have said that ZCPR3 is a great operating system but  that
  22. one  must have a hard disk system to use it.   I would like to put that myth
  23. to  rest.   ZCPR3 CAN BE USED AND USED VERY EFFECTIVELY ON A  COMPUTER  WITH
  24. FLOPPY  DISK DRIVES ONLY.   I have Z-System running on six 8-bit  computers,
  25. and  only  one  has a hard disk drive (that's the Z-Node  machine,  which  I
  26. almost never get to use myself).   Admittedly,  ZCPR3 runs much better on  a
  27. system  with  a hard disk drive and/or RAM drive,  but everything runs  much
  28. better  on such a system.   Z-System no more requires a hard disk than  does
  29. standard CP/M.
  30.  
  31.  
  32.              Squeezing More Performance Out of a Floppy System
  33.  
  34.      A full-up Z-System with shells,  error handlers,  a search path, and an
  35. extended  command processor (ECP) can make for a lot of disk  accesses,  and
  36. this can slow operation down.  However, there is a simple technique that can
  37. help  a  great deal and can even benefit a hard  disk.   To  understand  the
  38. technique,  you  need  a little background on how the disk operating  system
  39. (DOS  -- either BDOS,  ZRDOS,  or P2DOS) works and how data are stored on  a
  40. diskette.
  41.  
  42.      Let's take up the second matter first.   Data on a diskette are  stored
  43. in circular tracks numbered from the outside of the diskette.  The first two
  44. tracks  (sometimes  one,  sometimes  three) are reserved for  the  operating
  45. system code and are called "the system tracks."  When the computer is  first
  46. turned  on  or when the reset button is pressed,  the microprocessor  starts
  47. running  a program stored in a ROM (read-only memory  chip).   This  program
  48. contains  instructions that initiate a process whereby the entire  operating
  49. system  is read in from these system tracks.   Additionally,  with each warm
  50. boot,  initiated  by the user with a control-C command or  automatically  by
  51. some programs when they are done,  the command processor code (and generally
  52. the DOS as well) are reloaded into memory from the system tracks.è
  53.      With  the next track inside the system tracks begins what is called the
  54. directory of the disk.   Like the index of a book, the directory has entries
  55. for each file stored on the disk containing such information as the name  of
  56. the  file  and  where on the disk the data for that file  are  stored.   The
  57. directory  has  a  fixed size and can accommodate only  a  fixed  number  of
  58. entries  (that is why if you have many small files,  you can sometimes get a
  59. "disk  full"  message even when there appears to be plenty of  room  on  the
  60. disk).   The  rest  of  the disk is devoted to the storage of the  data  for
  61. files.
  62.  
  63.      Now let's look at what DOS does when it wants to read a file.  First it
  64. has to find out where the file is stored, so it moves the drive heads to the
  65. directory.   Since the directory, unlike the index of a book, is not sorted,
  66. DOS  must  start at the beginning and read through the  directory  until  it
  67. finds  the  entry for the file it wants.   Once it knows where to go on  the
  68. diskette to find the data,  it moves the heads to the proper track and reads
  69. the data.   This head movement or seeking,  as it is called, can take a long
  70. time,  especially with older,  slower floppies.   Even a fast,  modern drive
  71. that  steps at a rate of six milliseconds per track will take nearly half  a
  72. second  to  seek from the directory track to the innermost track on  an  80-
  73. track drive.   Clearly files located near the directory track will load much
  74. faster than those located near the inside of the diskette.   And files  with
  75. directory  entries  near the beginning of the directory will have  a  slight
  76. edge over those with their entries at the end.
  77.  
  78.      I think you can now see what we should do to speed things up.   But two
  79. further  questions face us:  1) which are the files whose loading times  are
  80. critical  to  the  performance of a Z-System,  and 2) how can  one  get  the
  81. operating  system  to  a)  place directory entries for these  files  at  the
  82. beginning  of the directory and b) place the data for these files on  tracks
  83. near the directory?
  84.  
  85.      The second question is easy to answer.   Whenever DOS writes a file out
  86. to disk,  it uses the first free entry in the directory and places the  data
  87. in  the  outermost available space on the disk.   After a diskette has  been
  88. used  for  a  while  and files have been  written  and  erased  many  times,
  89. directory entries and file data can be rather disordered.   However,  if one
  90. starts with a freshly formatted disk (with only the operating sysgen'ed onto
  91. it),  files  copied to it will fill the directory and data spaces exactly in
  92. order.
  93.  
  94.      Now comes the question as to which files should be written to the fresh
  95. disk first.   The general answer is:  the ones that are accessed most often.
  96. In  a  Z-System  one must be careful when trying  to  answer  this  question
  97. because  there are files that are accessed automatically by the system,  and
  98. the user may not even be aware of them.   Here are my suggestions for  files
  99. to put on the list.  The exact order in which they are copied to the disk is
  100. not that critical.
  101.  
  102.      If  you  are like me and have been known to make typing  mistakes  when
  103. entering  commands,  then you will want the ZCPR3 error handler to be calledèin so that you can correct the mistake.   Put your favorite error handler on
  104. the list (mine is VERROR).   If you use an extended command processor  (more
  105. on  that subject in a future column),  you should put it and its  associated
  106. files  on  the  list.   I use ARUNZ,  a program that enables  one  to  store
  107. hundreds of alias scripts in a single, small text file, ALIAS.CMD.  Whenever
  108. a command cannot be executed either as a built-in command (in the FCP,  CPR,
  109. or  RCP) or as a transient (COM file),  then ARUNZ is invoked,   It tries to
  110. find  the  given  command name in ALIAS.CMD.   Since  these  operations  are
  111. performed  often,  I  include ALIAS.CMD and ARUNZ.COM on my list  of  files.
  112. Another popular extended command processor is LX (or LRUNZ),  a program that
  113. extracts programs from a library (COMMAND.LBR) of COM files.  If you use LX,
  114. then put LX.COM and COMMAND.LBR on your list.
  115.  
  116.      The  next  category  of  programs  to  consider  is  shells  and  their
  117. associated files.   I make frequent use of the history shell,  HSH, with its
  118. command  line  history  file HSH.VAR.   It allows one  to  perform  complete
  119. editing  of  the command line,  just as if one were entering the  line  with
  120. WordStar.   In addition, it lets one recall commands issued previously (even
  121. on  a previous day!),  edit them as desired,  and run them  again.   What  a
  122. pleasure to run a system like this!   Another command-line shell,  VCED (for
  123. video  command line editor) performs similarly,  and the choice between them
  124. is a matter of personal preference.   Both of them can really slow down  the
  125. operation  of  a  floppy-based  system  if not placed  on  the  diskette  as
  126. described above.  Other commonly used shells are VFILER (with the VFILER.CMD
  127. macro  file)  and  MENU  and  VMENU (with  their  menu  files  MENU.MNU  and
  128. MENU.VMN).  If you use any of them, add them to the list.
  129.  
  130.      The last category of files I include on the list is files that I invoke
  131. manually  very often and want to see the results of fast.   This  especially
  132. includes directory programs (SD and XD,  for example).   I also hate to wait
  133. for my text editor (PMATE), so it is on my list.
  134.  
  135.      Let  me  finish by mentioning some files that I do not include  on  the
  136. list.   Obviously  I don't include files I rarely use,  such as  the  system
  137. segments  (SYS.RCP,  SYS.ENV,  etc.) that are used rarely except at coldboot
  138. time.   I  also do not include programs that take a fairly long time to  run
  139. anyway  or  which are generally run in batch mode.   I  put  assemblers  and
  140. linkers  in this category.   With them,  most of the time is spent  actually
  141. computing or reading and writing the files on which they operate.  Who cares
  142. if  the assembler loads in 2 rather than 5 seconds if the assembly takes  20
  143. seconds  or more anyway.   I would probably also leave off the list programs
  144. that I tend to spend a lot of time in once they are loaded.  Turbo Pascal is
  145. an  example.   Since it has a built-in editor and keeps the source code  and
  146. object code in memory simultaneously, one generally lives inside Turbo while
  147. developing a program.   Batch programs,  like SUB, SUBMIT, or ZEX, would not
  148. be  on  my list.   Since they initiate a long,  time-consuming  sequence  of
  149. events anyway, why be in such a hurry to get things started.
  150.  
  151.      The mention of ZEX reminds me of one final hint on how to expedite  the
  152. use of this speed-up technique.   I make a batch file for ZEX (you could use
  153. SUBMIT just as well) with all the copy commands in the order in which I want
  154. the  files to be on the new disk.   The script for a MAKESYS.ZEX file to  beèrun  from  the A drive to make a new system diskette on drive B  might  look
  155. something like
  156.  
  157.                 MCOPY B:=HSH.*
  158.                 GO B:=ARUNZ.COM,ALIAS.CMD
  159.                 GO B:=VERROR.COM
  160.                 GO B:=VFILER.*
  161.                 GO B:=SD.COM,XD.COM
  162.                 GO B:=*.* N
  163.                 GO B1:=1:*.* N
  164.  
  165. If you leave out a file and have to repeat the process, it is much easier to
  166. edit  the  batch  file than to enter manually all the copy  commands  again,
  167. especially since you'll probably accidentally skip another file and have  to
  168. repeat  the procedure still again!   The last two lines copy all the rest of
  169. the  files in user areas 0 and 1;  the 'no replace' option 'N'  makes  MCOPY
  170. skip over any files already on the destination directory.  If you have files
  171. in other user areas, add lines for them, too.
  172.  
  173.  
  174.                                  ----------
  175.  
  176.                           New Program Suggestions
  177.  
  178.      We  now  turn  to  the  promised subject for  this  month's  column  --
  179. suggestions for new programs or program enhancements.   I hope some  readers
  180. will  decide to take a shot at writing these programs and submitting them to
  181. ZSIG.  If so, I recommend that you let me know in one of the ways (including
  182. writing  to  me) described in my column in the last issue  of  The  Computer
  183. Journal.   That  way we won't have two versions of a program that have to be
  184. integrated.   Those  of  you who perhaps do not have the  assembly  language
  185. programming knowledge can still contribute by sending in further suggestions
  186. and ideas.   As I said in the last column, the real ingenuity in software is
  187. not so much in the actual coding as in the conceiving of new program ideas.
  188.  
  189.  
  190.                                   SETPATH
  191.  
  192.      The  path  feature  of ZCPR3,  which allows a COM  file  to  be  loaded
  193. automatically  from a drive and user area other than the one from which  the
  194. command  was issued,  is probably the most used (and least noticed) feature.
  195. The utility used to support this capability,  PATH.COM, operates in only two
  196. ways.   When  invoked  with no command tail,  it displays  the  search  path
  197. currently  in effect,  listing each path element symbolically (possibly with
  198. '$'  characters  for current drive or user),  in DU  format,  and  in  named
  199. directory format.  When invoked with a command tail, the tail is interpreted
  200. as a new search path, replacing the old one.
  201.  
  202.      I have often wanted to make simple changes to the path,  such as adding
  203. a  new element at the beginning or end of the path.   Later I want to remove
  204. it.   With  the  present PATH command one has to enter a complete  new  path
  205. specification  each time.   I would propose a new program,  which  might  beècalled  SETPATH,  that  would offer more flexible options.   The syntax  for
  206. SETPATH would be as follows:
  207.  
  208.         SETPATH [/option element-list] [/option element-list] ...
  209.  
  210. The following option specifiers would be recognized:
  211.  
  212.         C       clear existing path and append elements listed
  213.         A       append path element list to existing path
  214.         P       prefix path element list to beginning of existing path
  215.         D or R  delete (remove) listed elements from existing path
  216.  
  217. After the new path is built and loaded,  the final path would be  displayed.
  218. Option 'C' would be the default option if no option is given explicitly, and
  219. thus  SETPATH would work the same as PATH when used the same way.   Just  to
  220. make sure that the syntax is clear, here is an example SETPATH command:
  221.  
  222.                 SETPATH /A NEW1 NEW2 /D OLD2 /P NEW3
  223.  
  224. If the old path had been "OLD1 OLD2",  then the new path would be "NEW3 OLD1
  225. NEW1 NEW2".
  226.  
  227.      There  are some technical details to consider.   The new path should be
  228. built up in a temporary buffer and its length checked only at the end, since
  229. additions made before deletions might make the path temporarily longer  than
  230. allowed.   If the final path is too long, one should probably leave the path
  231. as it was,  display an error message,  and ring the console bell.  One might
  232. also want to set the ZCPR3 program error flag (and clear it when the command
  233. succeeds).   For  security reasons,  named path elements must be checked for
  234. passwords,  and drive/user path elements must be checked against the maximum
  235. drive and user values specified in the environment.   Naturally,  like PATH,
  236. the entire utility should work only if the wheel byte is on.
  237.  
  238.      To be complete and thorough, one might want to recognize a leading pair
  239. of slash characters not as an option but as a single slash in a path element
  240. name.   Otherwise one would have no way to use a named directory whose  name
  241. begins with a slash.   The first version of SETPATH could omit this feature,
  242. since  it  is  not critical.   A command tail with '//' or '/'  only  should
  243. display a built-in help message.
  244.  
  245.      There  is  an issue with the 'D' and 'R' options.   In  some  cases  an
  246. element may appear more than once in a path.   My default path, for example,
  247. is  "SYS ASM MODEM SYS".   SYS appears both at the beginning,  so that it is
  248. searched  first,  and  at the end,  so that programs that  access  the  root
  249. element  will  also  use SYS.   My choice would be to make the 'D'  and  'R'
  250. options delete only one occurrence of an element.   Perhaps 'D' could delete
  251. starting at the beginning of the path and 'R' could remove starting from the
  252. end of the path.   Usually,  of course,  the path element would appear  only
  253. once,  and both options would give the same result.  I'm not completely sure
  254. what  should be done when the element to be deleted is not found.   The path
  255. should  still be built,  and an error message should probably be  displayed,
  256. but the ZCPR3 program error flag should probably not be set.è
  257.      SETPATH,  as described here,  would be fairly easy to write,  since  it
  258. could borrow most of its code from the present PATH command.  An alternative
  259. enhanced  PATH command,  a video program which might be called VPATH,  would
  260. display  the  path in a full-screen format and allow the user  to  edit  the
  261. path,  inserting  and  deleting elements using cursor controls  and  editing
  262. commands.   My  present  feeling is that such a command would  be  overkill.
  263. SETPATH  would be adequate and would have the advantage that,  not requiring
  264. interactive input, it could be run from batch files and aliases.
  265.  
  266.  
  267.                                    SETNDR
  268.  
  269.      The named directory facility in ZCPR3 can be very convenient.   I  find
  270. it handy to put all my assembly language tools in a directory called ASM and
  271. my modem related programs in a directory called MODEM.  It is much easier to
  272. remember  the names than the particular user numbers chosen.   Some programs
  273. make  automatic use of named directories.   The HELP program,  for  example,
  274. looks  in  a  directory  named  HELP  for  the  file  containing  the   help
  275. information.   Echelon's  disk  cataloguing program DISCAT uses a  directory
  276. named  CAT  to keep the catalogues and a directory BACKUP to  determine  the
  277. drive holding the diskette to be catalogued.
  278.  
  279.      A program similar in concept to SETPATH,  which might be called SETNDR,
  280. would be useful for making simple manual additions, deletions, or changes to
  281. the named directory register (NDR).  For example, as mentioned above, DISCAT
  282. catalogues diskettes in the drive containing a directory named  BACKUP.   In
  283. order to make DISCAT work with a different drive, one would normally have to
  284. have  or make another NDR file and load it with LDR.   SETNDR would be  much
  285. easier to use.
  286.  
  287.      SETNDR could be a very simple, short program with the following syntax:
  288.  
  289.         SETNDR DU:              remove name associated with area DU:
  290.         SETNDR DIR:             remove directory with name DIR
  291.         SETNDR DU:NAME          assign NAME to area DU:
  292.         SETNDR DIR:NAME         change directory DIR to NAME
  293.  
  294. A  second name on the command line could be used to assign a password to the
  295. directory.
  296.  
  297.         SETNDR DU:NAME PASS     define new name and password
  298.         SETNDR DIR:NAME PASS    assign new name and password
  299.  
  300. Before  assigning a name to a drive/user area,  the program should check  to
  301. make  sure that the name is not already assigned to a different DU.   If  it
  302. is, there are three reasonable possibilities.
  303.  
  304.    1.   the  program could display an error message and refuse to make  the
  305.         change;
  306.    2.   the program could delete the existing assignment,  provided it is to
  307.         a  user-accessible area (i.e.,  not password protected or beyond theè        maximum drive and user values specified by the environment); or
  308.    3.   the program could report the situation to the user and prompt as  to
  309.         whether  the  existing assignment should be deleted (again  provided
  310.         the assignment to be deleted is to a user-accessible area).
  311.  
  312. My  preference  is  the second choice,  but a message  should  be  displayed
  313. reporting the assignment that has been deleted in case it was unintentional.
  314.  
  315.      Like SETPATH,  this program should be fairly easy to code.   The parser
  316. built  into ZCPR3 would do almost all of the work required to interpret  the
  317. command line.   The programmer would only have to detect the absence of  any
  318. command  tail or one with only '//'.   In these cases a built-in help screen
  319. should  be  displayed.   Most security issues would also be handled  by  the
  320. ZCPR3 command-line parser.  However, the program code should check the wheel
  321. byte and prohibit changes if it is not set.
  322.  
  323.      If the ZCPR3 parser is used,  some possibly erroneous input would  pass
  324. undetected.  For example, the command lines
  325.  
  326.                 SETNDR DU:NEWNAME DIR:
  327.                 SETNDR DU:NEWNAME U:
  328.  
  329. would  ignore the password field (since the parser would see no file  name).
  330. Also, a command like
  331.  
  332.                 SETNDR NEWNAME
  333.  
  334. will  assign  the new name to the currently logged-in area.   The latter  is
  335. probably  acceptable  (perhaps desirable).   In any case,  if one  wants  to
  336. control these cases, the code would have to double check the actual command-
  337. line tail and not rely only on the default file control blocks.
  338.  
  339.      There  is already a utility called LDSK (load disk)  for  automatically
  340. setting up named directories after one switches diskettes in a floppy drive.
  341. If  a  user  area on the diskette contains a file whose name begins  with  a
  342. hyphen, then LDSK assigns that name (not including the hyphen) to that area.
  343. LDSK might have some code one could borrow for SETNDR.
  344.  
  345.  
  346.                               Enhanced IF.COM
  347.  
  348.      Conditional command processing, though rarely invoked directly in user-
  349. entered commands,  gives ZCPR3 alias and batch scripts tremendous power  and
  350. flexibility.  Scripts can test such conditions as:
  351.  
  352.         whether  a  previously run program has set or  cleared  the  program
  353.         error flag;
  354.  
  355.         whether  a parameter value has been specified or omitted in an alias
  356.         invocation;
  357.  
  358.         whether a specified file exists;è
  359.         whether the file not only exists but has non-zero length;
  360.  
  361.         whether one of the ten user registers contains a specified value;
  362.  
  363.         whether the wheel byte is set or clear; or
  364.  
  365.         whether or not a terminal definition (TCAP) is loaded.
  366.  
  367.      Some  of the conditional testing is performed with the  ZCPR3  resident
  368. FCP  (flow command package).   Optionally,  the FCP can pass on  conditional
  369. testing to the transient program IF.COM.  The user can also force invocation
  370. of  the  transient IF processor by including a directory specification  with
  371. the command,  such as "A0:IF..." or even just ":IF...".   Since IF.COM  does
  372. not  have  to  be resident and permanently reduce the memory  available  for
  373. program  operation,  it can be a bigger and more capable  program.   I  will
  374. mention here some enhancements that would be useful in IF.COM.
  375.  
  376.      Current  IF processing allows one to determine the presence or  absence
  377. of  a  parameter with the NULL option.   Howard Goldstein has  requested  an
  378. ambiguity option:
  379.  
  380.                 IF AMBIG AFN
  381.  
  382. This  would  allow an alias script to determine if a parameter passed to  it
  383. was ambiguous,  so that an error message could be echoed instead of  passing
  384. an  ambiguous  file specification to a program that requires an  unambiguous
  385. file name.
  386.  
  387.      The  current  IF processing allows one to determine the  existence  and
  388. non-zero size of files with the EXIST and EMPTY options.  It would be useful
  389. to be able to test the attributes of files, as in
  390.  
  391.         IF ARCHIVE AFN          do files have archive bit set
  392.         IF RO AFN               are files read-only
  393.         IF RW AFN               are files read-write
  394.         IF WP AFN               are file wheel protected
  395.         IF SYS AFN              are files of system (SYS) type
  396.         IF DIR AFN              are files of directory (DIR) type
  397.  
  398.      The current version of IF.COM allows a test of the form
  399.  
  400.                 IF AFN1=AFN2
  401.  
  402. which compares two possibly ambiguous file specifications.   It can be  used
  403. fairly  generally  to  compare  command line tokens,  as  in  the  following
  404. VFILER.CMD macro script:
  405.  
  406.                 IF %PT=LBR;LDIR %$;ELSE;ECHO NOT LBR FILE;FI
  407.  
  408. VFILER  replaces  the  parameter %PT with the type  of  the  file  currently
  409. pointed  to.   If  the pointed-to file is a library,  its directory will  beèdisplayed; otherwise an error message will be echoed.
  410.  
  411.      There  have  been  a  number  of times  when  I  have  wanted  to  test
  412. inequalities.   ARUNZ  alias scripts can read values from the user registers
  413. and from memory locations.  Sometimes one would like to test for values that
  414. are less than or greater than some other value.   Thus it would be handy  to
  415. have  tests  other  than just equality.   Equality is the  easiest  to  code
  416. because  the ZCPR3 command line parser already handles the equal sign (since
  417. it is used in commands such as REN and CP).  For the extended comparisons, I
  418. would propose a syntax of the form
  419.  
  420.                 IF TOKEN1 TOKEN2 RELATION
  421.  
  422. The first two tokens (words) on the command line will be parsed by the ZCPR3
  423. command processor and placed into the two default file control blocks at 5Ch
  424. and 6Ch.  The IF.COM code would have to scan the command tail saved starting
  425. at  memory  location 80h to see if there is a third  token.   The  following
  426. tokens could be recognized:
  427.  
  428.                 EQ or =         token1 same as token2
  429.                 NE or <>        token1 not same as token2
  430.                 LT or <         token1 less than token2
  431.                 LE or <=        token1 less than or same as token2
  432.                 GT or >         token1 greater than token2
  433.                 GE or >=        token1 greater than or same as token2
  434.  
  435. Any  wildcard  characters  in either token would be taken as  equal  to  any
  436. corresponding character in the other token.   Thus "ABC*" would be equal  to
  437. "?BC",  since  the  "A" in the first position matches the "?" in the  second
  438. token  and  the "*" in the first token matches all the blank spaces  in  the
  439. last five character positions in the second token.
  440.  
  441.      I think these ideas should be enough to keep you busy for a  while!   I
  442. have  several  possible  subjects  for my next column but  will  await  your
  443. response before deciding what to cover.  Please send in your suggestions.
  444.  
  445. [This article was originally published in issue 26 of The Computer Journal,
  446. P.O. Box 12, South Plainfield, NJ 07080-0012 and is reproduced with the
  447. permission of the author and the publisher. Further reproduction for non-
  448. commercial purposes is authorized. This copyright notice must be retained.
  449. (c) Copyright 1987, 1991 Socrates Press and respective authors]
  450.