home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / mslang / as / hdr.asm < prev    next >
Assembly Source File  |  1985-12-31  |  10KB  |  244 lines

  1.         PAGE    60, 132
  2. TITLE   HDR     22-Feb-85       Device Driver Header                    |
  3.  
  4. ;-----------------------------------------------------------------------|
  5. ;                                                                       |
  6. ;       Device Driver Library                                           |
  7. ;               Device Driver Header                                    |
  8. ;                                                                       |
  9. ;-----------------------------------------------------------------------|
  10. ;       REVISION HISTORY                                                |
  11. ;                                                                       |
  12. ; Number    DD-MMM-YY             WHO                   WHY             |
  13. ;-------|---------------|-----------------------|-----------------------|
  14. ; 0.0   |   22-Feb-85   | Frank Whaley          | Initial Release       |
  15. ;-----------------------------------------------------------------------|
  16.  
  17.         PAGE
  18. ;-----------------------------------------------------------------------|
  19. ;       Equates                                                         |
  20. ;-----------------------------------------------------------------------|
  21.  
  22. StkSiz  EQU     2048                    ; local stack size
  23.  
  24.         PAGE
  25. ;-----------------------------------------------------------------------|
  26. ;       Group Selection                                                 |
  27. ;-----------------------------------------------------------------------|
  28.  
  29. PGROUP  Group   PROG, TAIL
  30. DGROUP  Group   DATA, DTAIL
  31.  
  32. PROG    Segment Para Public 'PROG'
  33. PROG    EndS
  34.  
  35. DATA    Segment Para Public 'DATA'      ; define first
  36. DATA    EndS
  37.  
  38.         Assume  CS:PROG, DS:DATA, ES:DATA, SS:DATA
  39.  
  40.         PAGE
  41. ;-----------------------------------------------------------------------|
  42. ;       Program Segment                                                 |
  43. ;-----------------------------------------------------------------------|
  44.  
  45. PROG    Segment Para Public 'PROG'
  46.  
  47.         Extrn   Init:Near,      MediaChe:Near,  BuildBPB:Near
  48.         Extrn   IoCtlIn:Near,   Input:Near,     ndInput:Near
  49.         Extrn   InputSta:Near,  InputFlu:Near,  Output:Near
  50.         Extrn   OutVerif:Near,  OutStatu:Near,  OutFlush:Near
  51.         Extrn   IoCtlOut:Near,  DevOpen:Near,   DevClose:Near
  52.         Extrn   RemMedia:Near
  53.  
  54.         ORG     0
  55.  
  56. HDR     Proc    Far
  57.  
  58. ;-----------------------------------------------------------------------|
  59. ;       Device Header                                                   |
  60. ;-----------------------------------------------------------------------|
  61.  
  62.         DD      -1                      ; -> next device
  63. ;       DW      theAttribute            ; you must enter attribute field
  64.         DW      8000H                   ; character only device
  65.         DW      Strategy                ; -> device strategy
  66.         DW      Interrupt               ; -> device interrupt
  67. ;       DB      theName                 ; you must put something here
  68.         DB      "MON     "              ; mono
  69.  
  70. ;-----------------------------------------------------------------------|
  71. ;       Code Segment Variables                                          |
  72. ;-----------------------------------------------------------------------|
  73.  
  74. RHptr   DD      (?)                     ; -> Request Header
  75. ssEntry DW      (?)                     ; entry SS
  76. spEntry DW      (?)                     ; entry SP
  77.  
  78.         PAGE
  79. ;-----------------------------------------------------------------------|
  80. ;       Device Strategy                                                 |
  81. ;                                                                       |
  82. ;       ENTRY : ES:BX -> Request Header                                 |
  83. ;                                                                       |
  84. ;       EXIT :  Request Header copied to ReqHdr                         |
  85. ;               all registers preserved                                 |
  86. ;                                                                       |
  87. ;-----------------------------------------------------------------------|
  88.  
  89. Strategy:
  90.  
  91.         MOV     Word Ptr CS:RHptr,BX    ; save request header ptr
  92.         MOV     Word Ptr CS:RHptr + 2,ES
  93.  
  94.         PUSHF                           ; (+1) save the world
  95.         PUSH    ES                      ; (+2)
  96.         PUSH    DS                      ; (+3)
  97.         PUSH    SI                      ; (+4)
  98.         PUSH    DI                      ; (+5)
  99.         PUSH    CX                      ; (+6)
  100.         PUSH    BX                      ; (+7)
  101.  
  102.         MOV     SI,BX
  103.         MOV     BX,ES
  104.         MOV     DS,BX                   ; DS:SI -> Request Header
  105.  
  106.         MOV     BX,Offset PGROUP:TAIL
  107.         MOV     CL,4
  108.         SHR     BX,CL
  109.         MOV     CX,CS
  110.         ADD     BX,CX
  111.         MOV     ES,BX
  112.         MOV     DI,Offset DGROUP:ReqHdr ; ES:DI -> ReqHdr
  113.  
  114.         CLD
  115.         XOR     CH,CH
  116.         MOV     CL,[SI]
  117.         REP     MOVSB                   ; copy Request Header
  118.  
  119.         POP     BX                      ; (+6) restore
  120.         POP     CX                      ; (+5)
  121.         POP     DI                      ; (+4)
  122.         POP     SI                      ; (+3)
  123.         POP     DS                      ; (+2)
  124.         POP     ES                      ; (+1)
  125.         POPF                            ; (+0)
  126.         RET
  127.  
  128.         PAGE
  129. ;-----------------------------------------------------------------------|
  130. ;       Device Interrupt                                                |
  131. ;                                                                       |
  132. ;       ENTRY : anything                                                |
  133. ;                                                                       |
  134. ;       EXIT :  all registers preserved                                 |
  135. ;                                                                       |
  136. ;-----------------------------------------------------------------------|
  137.  
  138. Interrupt:
  139.  
  140.         PUSH    DS                      ; (+1) save the world
  141.         PUSH    ES                      ; (+2)
  142.         PUSH    AX                      ; (+3)
  143.         PUSH    BX                      ; (+4)
  144.         PUSH    CX                      ; (+5)
  145.         PUSH    DX                      ; (+6)
  146.         PUSH    SI                      ; (+7)
  147.         PUSH    DI                      ; (+8)
  148.         PUSH    BP                      ; (+9)
  149.  
  150.         MOV     CS:ssEntry,SS           ; save entry SS
  151.         MOV     CS:spEntry,SP           ; and SP
  152.  
  153.         MOV     AX,Offset PGROUP:TAIL   ; set our DS, SS, BP, and SP
  154.         MOV     CL,4
  155.         SHR     AX,CL
  156.         MOV     CX,CS
  157.         ADD     AX,CX
  158.         MOV     BX,Offset DGROUP:MyStack
  159.         MOV     DS,AX
  160.         MOV     ES,AX
  161.         MOV     SS,AX
  162.         MOV     SP,BX
  163.         MOV     BP,BX
  164.  
  165.         ;
  166.         ; call our function
  167.         ;
  168.         MOV     AL,ReqHdr + 2           ; AL = Command Code
  169.         SHL     AL,1
  170.         CBW
  171.         MOV     SI,Offset DGROUP:FuncTab
  172.         ADD     SI,AX
  173.         CALL    Word Ptr [SI]
  174.  
  175.         ;
  176.         ; copy back Request Header
  177.         ;
  178.         LES     DI,RHptr                ; ES:DI -> original space
  179.         MOV     SI,Offset DGROUP:ReqHdr ; DS:SI -> our (updated) copy
  180.         CLD
  181.         XOR     CH,CH
  182.         MOV     CL,[SI]
  183.         REP     MOVSB                   ; copy Request Header
  184.  
  185.         MOV     SS,CS:ssEntry           ; restore original stuff
  186.         MOV     SP,CS:spEntry
  187.  
  188.         POP     BP                      ; (+8) restore
  189.         POP     DI                      ; (+7)
  190.         POP     SI                      ; (+6)
  191.         POP     DX                      ; (+5)
  192.         POP     CX                      ; (+4)
  193.         POP     BX                      ; (+3)
  194.         POP     AX                      ; (+2)
  195.         POP     ES                      ; (+1)
  196.         POP     DS                      ; (+0)
  197.         RET
  198.  
  199. HDR     EndP
  200.  
  201. PROG    EndS
  202.  
  203. TAIL    Segment Public 'PROG'           ; for finding end of code segment
  204. TAIL    EndS
  205.  
  206.         PAGE
  207. ;-----------------------------------------------------------------------|
  208. ;       Data Segment                                                    |
  209. ;-----------------------------------------------------------------------|
  210.  
  211. DATA    Segment Para Public 'DATA'
  212.  
  213.         Public  ReqHdr
  214.  
  215.         DB      StkSiz DUP (?)          ; our stack, overflows into code
  216. MyStack Label   Word
  217.  
  218. FuncTab Label Word
  219.         DW      Offset PGROUP:Init
  220.         DW      Offset PGROUP:MediaChe
  221.         DW      Offset PGROUP:BuildBPB
  222.         DW      Offset PGROUP:IoCtlIn
  223.         DW      Offset PGROUP:Input
  224.         DW      Offset PGROUP:ndInput
  225.         DW      Offset PGROUP:InputSta
  226.         DW      Offset PGROUP:InputFlu
  227.         DW      Offset PGROUP:Output
  228.         DW      Offset PGROUP:OutVerif
  229.         DW      Offset PGROUP:OutStatu
  230.         DW      Offset PGROUP:OutFlush
  231.         DW      Offset PGROUP:IoCtlOut
  232.         DW      Offset PGROUP:DevOpen
  233.         DW      Offset PGROUP:DevClose
  234.         DW      Offset PGROUP:RemMedia
  235.  
  236. ReqHdr  DB      256 DUP (?)             ; copy of Request Header
  237.  
  238. DATA    EndS
  239.  
  240. DTAIL   Segment Public 'DATA'           ; for finding end of data segment
  241. DTAIL   EndS
  242.  
  243.         END     HDR                     ; of HDR.ASM
  244.