home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / pdp8 / os278-src.tar.Z / os278-src.tar / userov.pa < prev   
Text File  |  1992-09-18  |  5KB  |  210 lines

  1. / BASIC User Overlay
  2.  
  3. / A user overlay is a PAL8 program that can be called by BASIC.  The overlay
  4. / uses 3 blocks (6 pages) of memory starting at 03400.  All user overlays
  5. / must reside on the system device.
  6.  
  7. / The standard calling sequence is as follows:
  8. /
  9. /    X$ = CAL$("FILE.EX",#)
  10. /    |            |      |
  11. /    |            |       - Number passed to overlay
  12. /    |             - Filename of the User Overlay
  13. /     - Literal containing information being passed back from overlay
  14. /     - If data being passed back > 18 character X$ must be Dimensioned
  15. /
  16. / Part 2 of this example shows how to retrieve the number and return it to X$.
  17. /
  18.  
  19. / If you wish to pass string data as well as a number then the following
  20. / applies.
  21. /
  22. / To activate string ability BASIC.OV must be patched.
  23. /     LOC 35430 from 5600 to 5270.
  24. /
  25. / *** The file name used in the CAL command MUST HAVE an extension.
  26. / If no extension exists the text string will be used as part of the overlay
  27. / name, thus causing an error in the file name lookup routine.
  28. /
  29. / The format with the patch is as follows:
  30. /
  31. / X$ = CAL$("FILNAME.EXTEXT STRING GOES HERE",#)
  32. / |                    |                      |
  33. / |                    |                       - Number passed to overlay
  34. / |                     - No space between filename and text
  35. /  - Literal containing information being passed back from overlay
  36. /  - If data being passed back > 18 character X$ must be Dimensioned
  37. /
  38. /  Part one of this example handles the string information.
  39.  
  40.     / Pointers into the Basic Run Time System (BRTS)
  41.  
  42.     SACXR=10    / Auto index for SAC
  43.     XR3=13        / Auto index for user code
  44.     XR4=14
  45.     XR5=15
  46.     SACLEN=32    / Contains length of SAC
  47.     TEMP1=63    / Contains 12 bit # passed by BASIC
  48.     SAVCHR=104    / Character save buffer
  49.     PSACM1=145    / Pointer to SAC - 1
  50.     SSMODE=212    / Set interpreter to string mode
  51.     PCH=1204    / Print a character to the console terminal
  52.             / Call with character in AC
  53.     GCH=1242    / Get a character from the console terminal
  54.             / 7 bit masked character left in SAVCHR
  55.             / If CTRL C or TRAP character found will not return
  56.     CTCCHK=1252    / Look for ^C and TRAP character
  57.             / If found will not return.
  58.     ERROR=1400    / Address for call to error overlay
  59.             / Does not reutrn.  Uses JMS address for error #
  60.     PSWAP=2071    / Monitor swap must execute in even intervals
  61.             / Monitor resides in High Field.  Must be swapped
  62.             / to field 0 before calling system handler, and
  63.             / swapped back before returning to BASIC
  64.  
  65.  
  66.     / Page zero constants used by the Basic Run Time System
  67.  
  68.     K4=106        / Contains    4
  69.     O10=177        / Contains   10
  70.     O15=144        / Contains   15
  71.     O17=175        / Contains   17
  72.     KESC=111    / Contains   33
  73.     O40=157        / Contains   40
  74.     K60=107        / Contains   60
  75.     KSEMI=73    / Contains   73
  76.     O77=127        / Contains   77
  77.     KBRACK=110    / Contains  133
  78.     IOMASK=62    / Contains  177
  79.     O200=171    / Contains  200
  80.     O377=174    / Contains  377
  81.     O7400=176    / Contains 7400
  82.     O7700=126    / Contains 7700
  83.  
  84.  
  85.     / Equates used by program
  86.  
  87.     AC7777=CLL CLA CMA
  88.     R3L=7014
  89.  
  90.  
  91. //
  92. //    User overlay starts here
  93. //
  94.  
  95.     *3400        / Block 1 of 3
  96.  
  97. START,    SKP CLA        / Init AC
  98.     JMS    ERROR    / Call ERROR overlay and indicate to the BASIC
  99.             / system that an error was generated in the
  100.             / User Overlay area.  JMS address is used to calculate
  101.             / the error number.  BASIC will not return here.
  102.  
  103.         ///////////////////
  104.         / Start of part 1 /
  105.         ///////////////////
  106.  
  107. //
  108. //    Process text passed by CAL routine
  109. //
  110.  
  111. PART1,    TAD    SACLEN    / Reset pointers to first character after filename
  112.     SNA        / If saclen = 0 no text
  113.     JMP    PART2
  114.     TAD    (-1
  115.     DCA    SACLEN
  116.     AC7777
  117.     TAD    SACXR
  118.     DCA    SACXR
  119.  
  120. PART1A,    TAD    SACLEN    / Check SAC to see if any data is left
  121.     SNA CLA
  122.     JMP    PART2    / No more text, now process number passed
  123.     CDF 10        / SAC buffer resides in field 1
  124.     TAD I    SACXR    / Get next character in SAC buffer
  125.     CDF        / Reset data field
  126.     JMS    PCH    / Print character on screen using BASIC
  127.     ISZ    SACLEN    / Update saclen count
  128.     NOP        / Will skip
  129.     JMP    PART1A    / Loop until all of text has been processed
  130.  
  131.  
  132.         ///////////////////
  133.         /  End of part 1  /
  134.         ///////////////////
  135.  
  136.         ///////////////////
  137.         / Start of part 2 /
  138.         ///////////////////
  139.  
  140.  
  141. //
  142. //    Process number passed by CAL routine
  143. //
  144.  
  145. PART2,    TAD    PSACM1    / Init pointer to SAC buffer
  146.     DCA    SACXR
  147.     TAD    TEMP1    / Get number passed by CAL command
  148.     R3L        / And send it back to literal used for CAL command
  149.     AND    (7    / Mask out one octal number
  150.     TAD    K60    / Convert it to an ASCII character
  151.     JMS    SACPUT    / and store it in SAC
  152.     TAD    TEMP1    / Repeat until for all four numbers
  153.     BSW
  154.     AND    (7
  155.     TAD    K60
  156.     JMS    SACPUT
  157.     TAD    TEMP1
  158.     RTR
  159.     RAR
  160.     AND    (7
  161.     TAD    K60
  162.     JMS    SACPUT
  163.     TAD    TEMP1
  164.     AND    (7
  165.     TAD    K60
  166.     JMS    SACPUT
  167.  
  168.             / Set SAC to number of characters sent
  169. SETLEN,    TAD    SACXR    / Get number of characters printed
  170.     CIA
  171.     TAD    PSACM1    / Current number of character inserted into SAC
  172.     DCA    SACLEN    / Number of characters already in SAC
  173.     JMP    SSMODE    / Return to BASIC
  174.  
  175. SACPUT,    0        / Store ASCII character passed in SAC buffer
  176.     CDF 10        / Change data field to where SAC resides
  177.     DCA I    SACXR    / Store the character in the SAC buffer
  178.     CDF        / Set data field back
  179.     JMP I    SACPUT    / Return to caller
  180.  
  181.  
  182.         /////////////////
  183.         / End of part 2 /
  184.         /////////////////
  185.  
  186.     PAGE
  187.  
  188.     / Zero out the remainder of the 6 pages of overlay space
  189.  
  190. ZBLOCK 200
  191.  
  192.     PAGE
  193.  
  194. ZBLOCK 200    / Block 2 of 3
  195.  
  196.     PAGE
  197.  
  198. ZBLOCK 200
  199.  
  200.     PAGE
  201.  
  202. ZBLOCK 200    / Block 3 of 3
  203.  
  204.     PAGE
  205.  
  206. ZBLOCK 200
  207.  
  208.     $
  209.  
  210.