home *** CD-ROM | disk | FTP | other *** search
- List-
-
- ;================================================
- ; The external library header code. This file
- ; contains the code to include at the start of any
- ; file that is to be accessed as an external runtime
- ; library (like IO.ASM). Immediately following this
- ; code must follow a sequential list of offsets
- ; to the routines within the library. The very
- ; last byte in the library must be the negative
- ; checksum of the entire file.
- ;
- ; BL must be set to the routine offset index (to
- ; access the table after this header).
- ;
- ; Upon entry the stack should look like this:
- ;
- ; | CS | - return segment (TOS)
- ; | SI | - original SI (must restore)
- ; | BX | - original BX (must restore)
- ; |<return>| - return offset
- ; | :: |
-
- Org 0
- Db 128 ;library marker
- Db 1,0 ;version number
- Dw Offset Library_Begin ;pointer to start of interface code
-
- Library_Begin Proc Far
- Seg Cs
- Pop Library_Return_Hi ;return segment
- Pop Si ;restore original SI
-
- Sub Bh, Bh
- Shl Bx ;two bytes/table entry
- Seg Cs
- Mov Bx, [Library_Branch_Table+Bx] ;load routine offset
- Seg Cs
- Mov Library_Dispatch, Bx ;save offset
- Pop Bx ;restore original BX
-
- Seg Cs
- Pop Library_Return_Lo ;store return address
- Seg Cs
- Call Library_Dispatch ;transfer to specified routine
-
- Seg Cs
- Push Library_Return_Hi
- Seg Cs
- Push Library_Return_Lo
- Ret ;return to original location
- Endp
-
- ;--- data
-
- Library_Return_Lo Dw ? ;return offset
- Library_Return_Hi Dw ? ;return segment
- Library_Dispatch Dw ? ;storage for routine offset
-
- Library_Branch_Table Label Word ;offsets should come after this
-
-