home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / z3doc / mex2z.azt / MEX2Z.ART
Encoding:
Text File  |  1993-06-07  |  5.9 KB  |  102 lines

  1. SETTING THE BAUD RATE WITH MEX2Z 
  2. by Rick Charnes, San Francisco, 9/20/87
  3.  
  4.     I'd like to share with fellow Z users the solution I created to a 
  5. problem I was having with the superb MEX2Z, the program by Bruce Morgen 
  6. and Jay Sage that gives Mex or MexPlus the ability to run as a "virtual 
  7. shell," i.e. to execute a ZCPR3 command and then automatically return to 
  8. itself.  The problem is described by Jay on p. 20 of the ZCPR33 User's 
  9. Guide.  For those who aren't familiar with it...
  10.  
  11.     The way MEX2Z works is as follows.  Suppose I want to exit MEX, edit 
  12. a file called JOE.LTR with VDE and then immediately return to MEX.  
  13. Rather than having to completely exit MEX, wait till returning to the Z 
  14. command line, and then entering commands, instead at the MEX command 
  15. line I can simply type 'CPM VDE JOE.LTR'.  Although 'VDE JOE.LTR' is of 
  16. course completely incomprehensible to MEX itself as they are not MEX 
  17. commands, we have created an alias in which MEX2Z.COM is invoked next.
  18. This picks up in memory the "trace" left behind by this MEX command line 
  19. and sends it to ZCPR3 for execution.  After this is run MEX2Z supplies 
  20. the command line ';MEX' which is now reinvoked and we are back to where 
  21. we started; a very nice shell.
  22.  
  23.     MEX2Z's ability to pick up this trace is fine for MEX command line 
  24. text, because it is left in memory * above * where MEX2Z runs so the 
  25. latter program can get to it.  Suppose, however, the information we wish 
  26. to restore from MEX is located in LOW TPA which is normally overwritten 
  27. by MEX2Z, or by any other program for that matter.  And it so happens 
  28. that the particularly information I want from the previous execution of 
  29. MEX -- the baud rate at which it was running -- is indeed kept in the 
  30. first record of memory.  I use PC- Pursuit to call Z- Nodes across the 
  31. country.  As of yet Telenet does not have it set up for 2400 baud 
  32. communication, so I have to run my Courier 2400 modem at 1200 when I use 
  33. this service.  When I am making local calls, however, I am free to gun 
  34. my accelerator to the max at 2400.  I have a *.MEX script file ("read" 
  35. file) containing a menu, login ID's and other information for each of 
  36. these two applications -- one for local 2400 calls and one called 
  37. PCP.MEX.  In each script file I set the baud rate appropriately, but 
  38. when MEX2Z reinvokes MEX it re-loads the program anew from its default 
  39. baud rate.
  40.    
  41.     How to deal with this problem?  Well, one solution pointed to by Jay 
  42. in this section is create a type-3 MEX2Z that will run at 8000h, high 
  43. above this information that we want.  But my knowledge of assembly 
  44. language is about as extensive as Bill Gates' knowledge of ZCPR33.  I 
  45. did nothing but get frustrated about it for a month or two, simply 
  46. trying to remember to do 'SET 1200' or 'SET 2400' as appropriate after 
  47. MEX2Z loaded MEX for the second time.  But then an idea came to me.
  48.  
  49.     I have the commercial MexPlus (easily the most exciting non-ZCPR3 
  50. program available for CP/M computing) and it has a (seldom-used) POKE 
  51. command.  The only time I've ever seen it used from within a script file 
  52. is when its author Ron Fowler releases a bug fix.  Ron very cleverly 
  53. writes his bug fixes as ... MexPlus script files!!  Using a program to 
  54. fix itself is clever.  This POKE command does exactly what the ZCPR3 
  55. POKE command does -- it changes a byte in memory.  So I started thinking 
  56. about ZCPR3 registers and the superb feature of our operating system:  
  57. the ability of sequential tasks to leave messages to each other.  I 
  58. settled on an out-of-the-way ZCPR3 register, number 6, which in my 
  59. system is located in memory at F3B6.  In my MEX read file for 2400 baud 
  60. calls I included a line 'POKE $F3B6 24' and in PCP.MEX 'POKE $F3B6 12'.  
  61. Here we are able to get a non-Z program to feed information to ZCPR3.  I 
  62. made a second copy of MEX2Z.COM and named one MEX2Z24.COM and the other 
  63. MEX2Z12.COM so their respective functions would be easy to remember.  As 
  64. an ASCII patch at the top of MEX2Z.COM you write the text of the command 
  65. line you would like it to re-execute after it exits.  I simply entered 
  66. the text ';MEX SET 1200' in MEX2Z12.COM whereas in MEX2Z24.COM I put 
  67. ';MEX SET 2400'.  I've renamed MEX.COM to REALMEX.COM.  My alias that 
  68. runs the whole shebang is:
  69.  
  70.    MEX realmex;resolve if eq $$r6 24;mex2z24;else;mex2z12;fi
  71.  
  72. When I run at 2400 baud my script file pokes ZCPR3 register #6 to 24.  
  73. Then when REALMEX.COM exits, the flow control checks the register, sees 
  74. its value and runs the appropriate version of MEX2Z, which returns the 
  75. favor by reloading MEX at the appropriate baud rate.  Note that RESOLVE 
  76. is necessary here.  Remember that ARUNZ builds its command line and sets 
  77. the values of any of its parameters such as '$Rn' and '$Mnnnn' _at the 
  78. moment the alias is invoked._  None of the values that will be changed 
  79. by the operation of the alias have yet taken into effect.  At the moment 
  80. this alias is invoked my MEX scripts have not yet POKEd those memory 
  81. locations, hence the value of register 6 returned by the alias would be 
  82. the incorrect one.
  83.  
  84.     There are two ways to deal with this situation.  The one used here 
  85. is to preface the operation with the symbol in question with RESOLVE.  
  86. Note that the '$r6' symbol then becomes a parameter of RESOLVE.  Since 
  87. in an ARUNZ script we must enter '$$' to produce a '$', hence the need 
  88. for '$$r6' to provide the '$r6' symbol for RESOLVE.COM.
  89.  
  90.     The other solution would be to make two aliases out of it, as in:
  91.  
  92.     MEX realmex;mex2
  93.     REALMEX2 resolve if eq $$r6 24;mex2z;else;mex2z12;fi
  94.  
  95.     Ah, the multi-colored wonders of Z...
  96.  
  97.                                           Rick Charnes
  98.                                           San Francisco
  99.                                           (415) 826-9448
  100. ck Charnes
  101.                                           San Francisco
  102.                                           (415) 826-