home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / ddkit.zip / ENTRY.ASM < prev    next >
Assembly Source File  |  1986-06-03  |  3KB  |  76 lines

  1.          PUBLIC REQHDR,DONE,INVALID,DONE2,ERROUT,XFER
  2. ;
  3. ;request header pointer
  4. ;
  5. REQHDR   LABEL  DWORD
  6. REQHDRo  DW     ?       ;offset
  7. REQHDRs  DW     ?       ;segment
  8. ;
  9. ;        Strategy Entry Point
  10. ;
  11. STRAT_ENT:
  12.          MOV    CS:REQHDRo,BX             ;save offset of request header ptr
  13.          MOV    CS:REQHDRs,ES             ;save segment of request header ptr
  14.          RET                              ;far return
  15. ;
  16. ;        "Interrupt" Entry Point
  17. ;
  18. ;         Note: DOS's stack allows saving registers
  19. ;          but if your routines need more stack space than
  20. ;          that, it will be necessary to define a local stack.
  21. ;
  22. INT_ENT: 
  23.          PUSHF                  ;preserve flags
  24.          CLD                    ;  set up forward string operations
  25.          PUSH   SI              ;preserve registers
  26.          PUSH   AX              ;
  27.          PUSH   CX              ;
  28.          PUSH   DX              ;
  29.          PUSH   DI              ;
  30.          PUSH   BP              ;
  31.          PUSH   DS              ;
  32.          PUSH   ES              ;
  33.          PUSH   BX              ;
  34.          ;
  35.          LDS    BX,CS:REQHDR            ;DS:BX pts to request header
  36.          MOV    CX,[BX+CNT]             ;get byte count
  37.          MOV    AL,[BX+CMD]             ;get command code
  38.          CMP    AL,HIFUNC               ; check for invalid command code
  39.          JA     INVALID                 ;
  40.          XOR    AH,AH                   ;
  41.          ROL    AL,1                    ; convert to offset
  42.          LEA    SI,FUNTBL               ;set up ptr to function table
  43.          ADD    SI,AX                   ; select table entry
  44.          LES    DI,DWORD PTR [BX+BUF]   ;get buffer address ES:DI
  45.          PUSH   CS                      ;
  46.          POP    DS                      ;destination addr = DS:SI
  47.          JMP    WORD PTR [SI]           ;   and jump to it
  48. ;
  49. INVALID: MOV    AL,UNKCMD               ;unknown command error
  50.          SUB    [BX+CNT],CX             ;zero bytes transferred
  51. ERROUT:  MOV    AH,ERROR+REQDON         ;set error and done bits
  52.          JMP    SHORT   EXIT            ;
  53. ;
  54. DONE2:   MOV    AH,REQDON+BUSY          ;set done+busy bits in request header status byte
  55.          JMP    SHORT   EXIT            ;
  56. ;
  57. XFER:    LDS    BX,CS:REQHDR            ;
  58.          SUB    [BX+CNT],CX             ;return number of bytes transferred
  59. DONE:    MOV    AH,REQDON               ;set done bit in request header status byte
  60. EXIT:    LDS    BX,CS:REQHDR            ;
  61.          MOV    [BX+STAT],AX            ;request header status
  62.          ;
  63.          POP    BX                      ;restore registers
  64.          POP    ES                      ;
  65.          POP    DS                      ;
  66.          POP    BP                      ;
  67.          POP    DI                      ;
  68.          POP    DX                      ;
  69.          POP    CX                      ;
  70.          POP    AX                      ;
  71.          POP    SI                      ;
  72.          POPF                           ;
  73.          RET                            ;far return
  74. ;
  75.  
  76.