home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.whtech.com
/
ftp.whtech.com.tar
/
ftp.whtech.com
/
Geneve
/
9640news
/
CAT24
/
XOP.ARK
< prev
next >
Wrap
Text File
|
2006-10-19
|
6KB
|
195 lines
?
Nhe following document (C) Copyright 1988 Paul Charlton, ALL RIGHTS RESERVED
Things to know about the orginization of an XOP library under MDOS
All XOP libraries are called with "XOP @libnum,0" from a user or
system program, each library must do it's own processing of opcodes for
routines contained within the library.
Each XOP routine library can have 24k of directly mapped memory, which
is addressed from >2000 to >7fff when the library is called. If the library
needs more than 24k of memory for programs and data, it must do it's own
mapping of it's extra memory pages before using them.
All XOP libraries execute in 9640 mode, and generally can have interrupts
enabled while they are executing.
All XOP libraries can have only 1 entry point per XOP library number.
All XOP libraries have 1 power-up code entry point per XOP library number.
Each XOP library has an 8 byte descriptor which must be loaded into the
operating system tables. The bytes are as follows:
0 must be >00
1 page number of >2000 page for library
2 page number of >4000 page for library
3 page number of >6000 page for library
4-5 address of entry point for library subroutines
6-7 address of power-up entry for library subroutines
note that 1 library may have have more than one library number assigned to it,
and the 8 byte descriptor must be put in place for each of the library numbers.
*
* sample MDOS program to install a library:
* this is an application task which can be loaded from the Command Line...
* self-installing
*
AORG >0400
*
* get list of pages belonging to library
*
INSTAL LI R0,4
LI R1,PAGLST
LI R2,PAGLEN
XOP @SEVEN,0
*
* now to tell the OS where the library is
*
MOVB @H00,@>F114 map system header in at >8000
MOV @>8024,R1 get count of reserved library descriptors
MOV @>8026,R2 get number of used library desc.
S R2,R1 subtract number of used library desc.
JLT ERROR someone screwed up...no slots left
JEQ ERROR no slots left
*
* now to install another library
* we can do the following code more than once, if this library supports
* several entry points...
*
LIMI 0 it wouldn't do for another task to get
* started and call lib before it's really there
INC @>8026 one more lib used
INC R2 one more lib used
*
SLA R2,3 make it an index into the desc. table
A @>8020,R2 make it a pointer into the desc table
AI R2,>8000
*
MOVB @H00,*R2+ install descriptor ...
MOVB @PAGLST+1,*R2+
MOVB @PAGLST+2,*R2+
MOVB @PAGLST+3,*R2+
MOV @XOPENT,*R2+
MOV @XOPPWR,*R2+ done with descriptor
*
MOV @>8022,R1 get pointer to power up tables
FIXPWR MOV *R1,R0
JEQ PUTPWR
INCT R1
JMP FIXPWR
*
PUTPWR MOV @XOPPWR,*R1 stuff in the power vector for the OS
BL @POWERU
MOVB @HFE,>0102 take us out of the "run" state...
LIMI 2
JMP $ hang here until the scheduler stops us.
*
ERROR BLWP @0
*
H00 BYTE 0
HFE BYTE >FE
XOPENT DATA OPSTOP
XOPPWR DATA POWER1
*
* now for some sample library code: (part of same program as above)
*
AORG >2000
*
PAGLST BYTE 0
LIBPAG BYTE 0,0,0,0,0,0,0 put enough 0's to hold all pages for library
PAGLEN EQU $-PAGLST
BYTE 0
SEVEN DATA 7
*
* this is the power up entry for ctl-alt-del calls...
* which means that it is time to reclaim our memory pages
* so that they can't be allocated
*
POWER1 LI R3,LIBPAG
*
POWER2 LI R0,10
MOVB *R3+,R1
JEQ POWERU
SRL R1,8
CLR R2
XOP @SEVEN,0 get the page (OS privileged call)
JMP POWER2
*
* the remaining power-up code is used to initialize any data structures
* used by the library
*
POWERU
*
* but I don't have any in this sample...
*
RT this is how to exit a power-up routine
*
* now to parse the opcodes.
*
OPSTOP MOV R13,R2 let's map in their WS
MOV R2,R12
SRL R2,13
MOVB @>8114(R2),@>F115 at >a000
MOVB @>8115(R2),@>F116 in case their WS crosses a page boundary
*
ANDI R12,>1FFF
AI R12,>A000 all WS arguments are indexed from R12 now
MOV *R12,R1 get opcode
*
CI R1,MAXCOD
JL OPOK
SETO *R12 bad opcode.
RTWP
*
OPOK CLR *R12 ok so far, though an opcode could change this
LI R0,14 this is only for getting virtual memory map
XOP @SEVEN,0 can delete this if you don't use these type args
* the map is at >1f00, and a max_cnt is at
* >1ffe (word)
* we need the virtual memory map only
* if their register arguments point to
* their virtual memory space
*
* the 8 bytes to map their execution address space, in case register
* arguments point to "execution addresses" is at >8114 when the library
* is started
*
SLA R1,2
MOV @OPTABL(R1),R1
BL *R1 do the code for the opcode
RTWP
*
OPTABL DATA OP1,OP2,OP3,OP4,OP5
DATA OP6
MAXCOD EQU $-OPTABL/2
*
* here is where you put your code...
*
* OP1 should return an identifier code unique to the library you are
* installing so that an application program can find the library it
* wants to use (since library numbers are assigned in the order the
* libraries are loaded, and your library won't always be at the same
* library number...the application has to poll the non-system defined
* libraries to find the one it wants
*
OP1 LI R1,UNIQUE
MOV R1,@2(R12) return it to caller's R1
OP2
OP3
OP4
OP5
OP6 RT
*
END
*
* i hope this is enough to get you started...have fun. <sic>
*
Download complete. Turn off Capture File.