home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / devdriv / ddd / typeahed.asm < prev    next >
Assembly Source File  |  1989-04-16  |  4KB  |  160 lines

  1.     PAGE    ,132
  2.  
  3. CSEG    SEGMENT
  4.     ASSUME    CS:CSEG, DS:NOTHING, ES:NOTHING
  5.     ORG    0000H            ; For all device drivers
  6.  
  7. Header    DD    -1            ; One device
  8.     DW    08000H            ; Character device
  9. StratA    DW    Strat            ; Strategy entrance
  10. IntrA    DW    Intr            ; Interrupt entrance
  11.     DB    'Typeahed'        ; 8 character dummy name
  12.  
  13. ;    Note: Put resident part of DDD here.
  14.  
  15.     TITLE    TYPEAHED - Expands type ahead buffer to 128 chars.
  16. COMMENT    $
  17.     Assemble, link and convert as follows:
  18.     MASM TYPEAHED;
  19.     LINK TYPEAHED;
  20.     EXE2BIN TYPEAHED TYPEAHED.SYS
  21.  
  22.     Install by adding the following line to CONFIG.SYS
  23.     DEVICE=TYPEAHED.SYS
  24.  
  25.     Program changes default buffer pointers to a new area
  26.     contained herein if this new area is within the 64K
  27.     limit of the segment at 0040. This new buffer is 128
  28.     characters (words) long and is always loaded even if
  29.     not used. The buffer is reset to empty. If the error
  30.     message is displayed, move the line nearer the beginning
  31.     of the CONFIG.SYS file. The command should always be
  32.     ahead of a RAMDisk loader.
  33.  
  34.     The address of the buffer is adjusted to bypass a bug
  35.     in the DOS 2.xx CON driver and ANSI.SYS.
  36.  
  37.     CAUTION: Do not type on the keyboard while this program
  38.     is being loaded by the device loader & CONFIG.SYS!!!
  39.     Your keystrokes will overlay the program if you do!
  40.     $
  41.  
  42. Chars        EQU    128
  43. Bytes        EQU    Chars*2
  44.  
  45. DATA        SEGMENT AT 00040H    ; ROM-BIOS Data area
  46.         ORG    0001AH
  47. BUFFER_HEAD    DW    ?
  48. BUFFER_TAIL    DW    ?
  49.         ORG    00080H
  50. BUFFER_START    DW    ?
  51. BUFFER_END    DW    ?
  52. DATA        ENDS
  53.  
  54. ;    Note: TYPEAHED has no resident code, just a buffer.
  55.  
  56. NewBuff    EQU    $            ; Buffer start
  57. EndBuff    EQU    $+Bytes            ; Buffer end
  58.  
  59. ;    End of Stay Resident portion of program.
  60. ;    ----------------------------------------
  61.  
  62. IOPacket    STRUC
  63. IO_CMDLEN    DB    ?
  64. IO_UNIT        DB    ?
  65. IO_CMD        DB    ?
  66. IO_STATUS    DW    ?
  67.         DB    8 DUP(?)
  68. IO_MEDIA    DB    ?
  69. IO_ADDRESS    DW    ?
  70.         DW    ?
  71. IO_COUNT    DW    ?
  72. IO_START    DW    ?
  73. IOPacket    ENDS
  74.  
  75. Init    PROC    FAR
  76.     ASSUME    DS:NOTHING, ES:NOTHING
  77.  
  78. Packet    DD    0            ; Request packet address
  79.  
  80. Strat:
  81.     MOV    WORD PTR Packet,BX    ; Save Packet info
  82.     MOV    WORD PTR Packet+2,ES
  83.     RET
  84.  
  85. Intr:
  86.     PUSH    BX            ; Save registers
  87.     PUSH    DS
  88.  
  89. ;    Note: Put initialization code here.
  90. ;    Save all registers used except DS & BX.
  91. ;    After code, restore same registers and
  92. ;    JMP to "Exit".
  93.  
  94.     PUSH    AX            ; Work area
  95.     PUSH    CX
  96.     PUSH    DX
  97.     MOV    AX,CS            ; From this segment address
  98.     SUB    AX,SEG DATA        ; subtract the DATA address
  99.     ADD    AX,(EndBuff-Header+0FFH)/16    ; and add buffer size
  100.     PUSH    AX
  101.     CMP    AX,01000H        ; Test within one 64K segment
  102.     JNB    TooHigh            ; No, do not change pointers
  103.     SUB    AX,(EndBuff-Header+0FFH)/16    ; Get segment diff.
  104.     MOV    CL,4            ; Convert to byte difference
  105.     SHL    AX,CL
  106.     MOV    BX,SEG DATA        ; Change info in DATA segment
  107.     MOV    DS,BX
  108.     ASSUME    DS:DATA
  109.     ADD    AX,OFFSET NewBuff+0FFH    ; Calculate offset of beginning
  110.     AND    AX,0FF00H        ; Drop last byte (DOS2.xx fix)
  111.     MOV    BUFFER_HEAD,AX        ; Put into buffer pointers
  112.     MOV    BUFFER_TAIL,AX
  113.     MOV    BUFFER_START,AX        ; and buffer addresses
  114.     ADD    AX,Bytes        ; Add in buffer byte size
  115.     MOV    BUFFER_END,AX        ; for buffer end address
  116.     MOV    DX,OFFSET Message    ; OK message
  117.     JMP    SHORT Installed
  118. TooHigh:
  119.     MOV    DX,OFFSET THMess    ; Too High message
  120. Installed:
  121.     PUSH    CS            ; Make DS = CS for DOS
  122.     POP    DS
  123.     ASSUME    DS:CSEG
  124.     MOV    AH,9            ; Output message
  125.     INT    021H
  126.     POP    AX            ; From highest segment
  127.     AND    AX,0FFF0H        ; rounded down
  128.     MOV    BX,CS            ; and this segment address
  129.     SUB    BX,SEG DATA        ; less the DATA address
  130.     SUB    AX,BX            ; find the paragraphs used
  131.     MOV    CL,4            ; Convert to bytes
  132.     SHL    AX,CL            ; to save for buffer
  133.     MOV    IntrA,AX        ; Save in work area
  134.     POP    DX
  135.     POP    CX
  136.     POP    AX
  137.     JMP    SHORT Exit        ; Exit installation
  138.  
  139. THMess    DB    'Too high in memory! No ',07H
  140. Message    DB    'TYPEAHED installed',0DH,0AH,24H
  141.  
  142. Exit:
  143.     ASSUME    DS:NOTHING
  144.     LDS    BX,DWORD PTR Packet    ; Restore Packet info
  145.     PUSH    AX
  146.     MOV    AX,IntrA        ; Retrieve buffer end
  147.     MOV    WORD PTR [BX+IO_ADDRESS],AX    ; Set memory request
  148.     POP    AX
  149. ;    Note: Change "Init" above to correct ending address
  150.     MOV    WORD PTR [BX+IO_ADDRESS+2],CS    ; to be resident
  151.     MOV    [BX+IO_STATUS],00100H    ; Set done bits
  152.     POP    DS            ; Restore registers used
  153.     POP    BX
  154.     RET                ; Exit device installaion
  155. Init    ENDP
  156.  
  157. CSEG    ENDS
  158.     END
  159.     END
  160.