home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / Geneve / 9640news / CAT24 / XOP.ARK < prev    next >
Text File  |  2006-10-19  |  6KB  |  195 lines

  1. ?
  2. Nhe following document (C) Copyright 1988 Paul Charlton, ALL RIGHTS RESERVED
  3.  
  4. Things to know about the orginization of an XOP library under MDOS
  5.  
  6. All XOP libraries are called with "XOP @libnum,0" from a user or
  7. system program, each library must do it's own processing of opcodes for
  8. routines contained within the library.
  9.  
  10. Each XOP routine library can have 24k of directly mapped memory, which
  11. is addressed from >2000 to >7fff when the library is called.  If the library
  12. needs more than 24k of memory for programs and data, it must do it's own
  13. mapping of it's extra memory pages before using them.
  14.  
  15. All XOP libraries execute in 9640 mode, and generally can have interrupts
  16. enabled while they are executing.
  17.  
  18. All XOP libraries can have only 1 entry point per XOP library number.
  19. All XOP libraries have 1 power-up code entry point per XOP library number.
  20.  
  21. Each XOP library has an 8 byte descriptor which must be loaded into the
  22. operating system tables. The bytes are as follows:
  23.  
  24. 0      must be >00
  25. 1      page number of >2000 page for library
  26. 2      page number of >4000 page for library
  27. 3      page number of >6000 page for library
  28. 4-5    address of entry point for library subroutines
  29. 6-7    address of power-up entry for library subroutines
  30.  
  31. note that 1 library may have have more than one library number assigned to it,
  32. and the 8 byte descriptor must be put in place for each of the library numbers.
  33.  
  34. *
  35. * sample MDOS program to install a library:
  36. * this is an application task which can be loaded from the Command Line...
  37. * self-installing
  38. *
  39.        AORG >0400
  40. *
  41. * get list of pages belonging to library
  42. *
  43. INSTAL LI   R0,4
  44.        LI   R1,PAGLST
  45.        LI   R2,PAGLEN
  46.        XOP  @SEVEN,0
  47. *
  48. * now to tell the OS where the library is
  49. *
  50.        MOVB @H00,@>F114       map system header in at >8000
  51.        MOV  @>8024,R1         get count of reserved library descriptors
  52.        MOV  @>8026,R2         get number of used library desc.
  53.        S    R2,R1             subtract number of used library desc.
  54.        JLT  ERROR             someone screwed up...no slots left
  55.        JEQ  ERROR             no slots left
  56. *
  57. * now to install another library
  58. * we can do the following code more than once, if this library supports
  59. * several entry points...
  60. *
  61.        LIMI 0                 it wouldn't do for another task to get
  62. *                             started and call lib before it's really there
  63.        INC  @>8026            one more lib used
  64.        INC  R2                one more lib used
  65. *
  66.        SLA  R2,3              make it an index into the desc. table
  67.        A    @>8020,R2         make it a pointer into the desc table
  68.        AI   R2,>8000
  69. *
  70.        MOVB @H00,*R2+         install descriptor ...
  71.        MOVB @PAGLST+1,*R2+
  72.        MOVB @PAGLST+2,*R2+
  73.        MOVB @PAGLST+3,*R2+
  74.        MOV  @XOPENT,*R2+
  75.        MOV  @XOPPWR,*R2+      done with descriptor
  76. *
  77.        MOV  @>8022,R1         get pointer to power up tables
  78. FIXPWR MOV  *R1,R0
  79.        JEQ  PUTPWR
  80.        INCT R1
  81.        JMP  FIXPWR
  82. *
  83. PUTPWR MOV  @XOPPWR,*R1       stuff in the power vector for the OS
  84.        BL   @POWERU
  85.        MOVB @HFE,>0102        take us out of the "run" state...
  86.        LIMI 2
  87.        JMP  $                 hang here until the scheduler stops us.
  88. *
  89. ERROR  BLWP @0
  90. *
  91. H00    BYTE 0
  92. HFE    BYTE >FE
  93. XOPENT DATA OPSTOP
  94. XOPPWR DATA POWER1
  95. *
  96. * now for some sample library code: (part of same program as above)
  97. *
  98.        AORG >2000
  99. *
  100. PAGLST BYTE 0
  101. LIBPAG BYTE 0,0,0,0,0,0,0     put enough 0's to hold all pages for library
  102. PAGLEN EQU  $-PAGLST
  103.        BYTE 0
  104. SEVEN  DATA 7
  105. *
  106. * this is the power up entry for ctl-alt-del calls...
  107. * which means that it is time to reclaim our memory pages
  108. * so that they can't be allocated
  109. *
  110. POWER1 LI   R3,LIBPAG
  111. *
  112. POWER2 LI   R0,10
  113.        MOVB *R3+,R1
  114.        JEQ  POWERU
  115.        SRL  R1,8
  116.        CLR  R2
  117.        XOP  @SEVEN,0          get the page (OS privileged call)
  118.        JMP  POWER2
  119. *
  120. * the remaining power-up code is used to initialize any data structures
  121. * used by the library
  122. *
  123. POWERU
  124. *
  125. * but I don't have any in this sample...
  126. *
  127.        RT                     this is how to exit a power-up routine
  128. *
  129. * now to parse the opcodes.
  130. *
  131. OPSTOP MOV  R13,R2            let's map in their WS
  132.        MOV  R2,R12
  133.        SRL  R2,13
  134.        MOVB @>8114(R2),@>F115 at >a000
  135.        MOVB @>8115(R2),@>F116 in case their WS crosses a page boundary
  136. *
  137.        ANDI R12,>1FFF
  138.        AI   R12,>A000         all WS arguments are indexed from R12 now
  139.        MOV  *R12,R1           get opcode
  140. *
  141.        CI   R1,MAXCOD
  142.        JL   OPOK
  143.        SETO *R12              bad opcode.
  144.        RTWP
  145. *
  146. OPOK   CLR  *R12              ok so far, though an opcode could change this
  147.        LI   R0,14             this is only for getting virtual memory map
  148.        XOP  @SEVEN,0          can delete this if you don't use these type args
  149. *                             the map is at >1f00, and a max_cnt is at
  150. *                             >1ffe (word)
  151. *                             we need the virtual memory map only
  152. *                             if their register arguments point to
  153. *                             their virtual memory space
  154. *
  155. *      the 8 bytes to map their execution address space, in case register
  156. *      arguments point to "execution addresses" is at >8114 when the library
  157. *      is started
  158. *
  159.        SLA  R1,2
  160.        MOV  @OPTABL(R1),R1
  161.        BL   *R1               do the code for the opcode
  162.        RTWP
  163. *
  164. OPTABL DATA OP1,OP2,OP3,OP4,OP5
  165.        DATA OP6
  166. MAXCOD EQU  $-OPTABL/2
  167. *
  168. * here is where you put your code...
  169. *
  170. * OP1 should return an identifier code unique to the library you are
  171. *     installing so that an application program can find the library it
  172. *     wants to use (since library numbers are assigned in the order the
  173. *     libraries are loaded, and your library won't always be at the same
  174. *     library number...the application has to poll the non-system defined
  175. *     libraries to find the one it wants
  176. *
  177. OP1    LI   R1,UNIQUE
  178.        MOV  R1,@2(R12)        return it to caller's R1
  179. OP2
  180. OP3
  181. OP4
  182. OP5
  183. OP6    RT
  184. *
  185.        END
  186. *
  187. * i hope this is enough to get you started...have fun. <sic>
  188. *
  189.  
  190.  
  191.  
  192. Download complete.  Turn off Capture File.
  193.  
  194.  
  195.