home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / asm / wasm / library.asm < prev    next >
Assembly Source File  |  1987-03-27  |  2KB  |  62 lines

  1.  List-
  2.  
  3. ;================================================
  4. ; The external library header code. This file
  5. ; contains the code to include at the start of any
  6. ; file that is to be accessed as an external runtime
  7. ; library (like IO.ASM). Immediately following this
  8. ; code must follow a sequential list of offsets
  9. ; to the routines within the library. The very
  10. ; last byte in the library must be the negative
  11. ; checksum of the entire file.
  12. ;
  13. ; BL must be set to the routine offset index (to
  14. ; access the table after this header).
  15. ;
  16. ; Upon entry the stack should look like this:
  17. ;
  18. ;   |   CS   | - return segment (TOS)
  19. ;   |   SI   | - original SI (must restore)
  20. ;   |   BX   | - original BX (must restore)
  21. ;   |<return>| - return offset
  22. ;   |   ::   |
  23.  
  24.  Org 0
  25.  Db 128                 ;library marker
  26.  Db 1,0                 ;version number
  27.  Dw Offset Library_Begin ;pointer to start of interface code
  28.  
  29. Library_Begin Proc Far
  30.  Seg Cs
  31.  Pop Library_Return_Hi  ;return segment
  32.  Pop Si                 ;restore original SI
  33.  
  34.  Sub Bh, Bh
  35.  Shl Bx                 ;two bytes/table entry
  36.  Seg Cs
  37.  Mov Bx, [Library_Branch_Table+Bx] ;load routine offset
  38.  Seg Cs
  39.  Mov Library_Dispatch, Bx ;save offset
  40.  Pop Bx                 ;restore original BX
  41.  
  42.  Seg Cs
  43.  Pop Library_Return_Lo  ;store return address
  44.  Seg Cs
  45.  Call Library_Dispatch  ;transfer to specified routine
  46.  
  47.  Seg Cs
  48.  Push Library_Return_Hi
  49.  Seg Cs
  50.  Push Library_Return_Lo
  51.  Ret                    ;return to original location
  52.  Endp
  53.  
  54. ;--- data
  55.  
  56. Library_Return_Lo Dw ?  ;return offset
  57. Library_Return_Hi Dw ?  ;return segment
  58. Library_Dispatch  Dw ?  ;storage for routine offset
  59.  
  60. Library_Branch_Table Label Word ;offsets should come after this
  61.  
  62.