home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1990 / 01 / ldm / drive720.asm < prev    next >
Encoding:
Assembly Source File  |  1989-11-07  |  7.3 KB  |  260 lines

  1.  
  2. PAGE  60,132
  3.  
  4. ;* ------------------------------------------------------- *
  5. ;                    DRIVE720.ASM                          *
  6. ;    DEVICE-Treiber zum Lesen/Schreiben von Disketten,     *
  7. ;    die auf 720 KB formatiert wurden (80 Tracks, 9 Secs), *
  8. ;    in AT-kompatiblen Rechnern                            *
  9. ;    Übersetzung:                                          *
  10. ;                  MASM    drive720;                       *
  11. ;                  LINK    drive720;                       *
  12. ;                  EXE2BIN drive720.exe drive720.sys       *
  13. ;            (C) 1990 Jochen Loewer & toolbox              *
  14. ;* ------------------------------------------------------- *
  15.  
  16. cseg     segment 'code'
  17.          assume  cs:cseg, ds:cseg
  18.  
  19.  
  20.          org     0
  21.  
  22. drive720 proc    far
  23.  
  24. header   dd      0FFFFFFFFh  ;   Link to next driver
  25.          db      01000000b   ;   Device attribute word
  26.          db      00001000b   ;   Device with IOCTL
  27.          dw      strategy
  28.          dw      commands
  29.  
  30. countlog db      1           ;   driver for 1 new block
  31.                              ;   device
  32.  
  33. req_off  dw      0           ;   for adr of
  34. req_seg  dw      0           ;   DEVICE request header
  35.  
  36. savespeed db      0          ;   for old speed
  37. biosspeed dw      0090h      ;   adr of bios variable
  38. bios2    dw      0040h
  39.  
  40. ; ---------------------------------------------------------
  41. strategy proc    far
  42.          mov     cs:req_off,bx
  43.          mov     cs:req_seg,es
  44.          ret
  45. strategy endp
  46.  
  47.  
  48. ; ----------------------------------------------------------
  49. commands proc    far
  50.          push    es
  51.          push    bx
  52.          push    ax
  53.  
  54.          les     bx,dword ptr cs:biosspeed
  55.          mov     al,es:[bx]
  56.          mov     byte ptr cs:savespeed,al
  57.          mov     byte ptr es:[bx],54h
  58.  
  59.          les     bx,dword ptr cs:req_off
  60.          cmp     byte ptr es:[bx+2],0 ;  Command: INIT ?
  61.          jne     do_rw                ;  no, do read/write
  62.          jmp     initial          ;  yes, jump to Initialize
  63. do_rw:
  64.          mov     al,cs:newdrive   ;   newdrive in blockunit
  65.          mov     es:[bx+1],al     ;   unit number of
  66.                                   ;   request header
  67.  
  68.          mov     ax,802h     ;   'magic' INT 2Fh 8(02)
  69.          int     2Fh         ;   will make the job for us !!
  70.  
  71.          pushf               ;   clean stack after INT 2Fh
  72.          pop     bx
  73.          add     sp,2
  74.          push    bx
  75.          popf
  76.  
  77. leavedev:
  78.          pushf
  79.          les     bx,dword ptr cs:biosspeed
  80.          mov     al,byte ptr cs:savespeed
  81.          mov     es:[bx],al
  82.          popf
  83.          pop     ax
  84.          pop     bx
  85.          pop     es
  86.          ret
  87. commands endp
  88.  
  89. ttlink   db      0FFh, 0FFh, 0FFh, 0FFh, 0 ,0
  90. bpb      db      0, 2, 0FFh, 1, 0, 2
  91.          db      64, 0,68h, 1
  92.          db      0, 2, 0, 9, 0, 1, 0, 0, 0
  93.          db      0,0,0,'NO NAME',32,32,32,32, 0, 2
  94.          db      20h
  95.          db      0, 50h, 0
  96.          db      0, 2, 2, 1, 0, 2
  97.          db      70h, 0, 0A0h, 5, 0F9h, 3, 0, 9, 0, 2
  98.          db      15 dup (0)
  99.          db      0FFh, 0FFh, 0FFh, 0FFh, 0FFh
  100. newdrive db      0
  101. resbpb   dw      bpb
  102.  
  103. drive720 endp
  104.  
  105. ; ----------------------------------------------------------
  106. ;   End of resident part
  107. ; ----------------------------------------------------------
  108.  
  109.  
  110. strout   proc    near        ;  string in (cs:dx) to con:
  111.          push    ax
  112.          push    ds
  113.          push    cs
  114.          pop     ds
  115.          mov     ah,9
  116.          int     21h
  117.  
  118.          pop     ds
  119.          pop     ax
  120.          ret
  121. strout   endp
  122.  
  123. error:
  124.          mov     ah,81h      ;   status : error+done
  125.          jmp     short err1
  126. good:
  127.          mov     ah,1        ;   status : ok + done
  128. err1:
  129.          lds     bx,dword ptr cs:req_off
  130.          xor     al,al
  131.          mov     [bx+3],ax   ;  put into status field
  132.          pop     ds
  133.          pop     bp
  134.          pop     di
  135.          pop     dx
  136.          pop     cx
  137.          pop     ax
  138.          pop     si
  139.          jmp     leavedev
  140.  
  141.  
  142. ; ----------------------------------------------------------
  143. ;    initialize and command line parsing
  144. ; ----------------------------------------------------------
  145.  
  146. initial:
  147.          push    si
  148.          push    ax
  149.          push    cx
  150.          push    dx
  151.          push    di
  152.          push    bp
  153.          push    ds
  154.          cld
  155.  
  156.          mov     ax,800h     ;   test if INT 2Fh
  157.          int     2Fh         ;   available                                                                ;*   get installed status
  158.          cmp     al,0FFh
  159.          jne     errinit
  160.  
  161.          lds     bx,dword ptr cs:req_off
  162.          mov     si,[bx+12h] ;   get command line
  163.          mov     ax,[bx+14h] ;   string in ds:si
  164.          mov     ds,ax
  165.  
  166.  
  167. scanchar:
  168.          lodsb
  169.          cmp     al,'/'
  170.          je      getdrive    ;   get x in /D:x
  171.          cmp     al,0Dh      ;   end before /D:x ?
  172.          je      synerr
  173.          cmp     al,0Ah
  174.          je      synerr
  175.          cmp     al,0
  176.          jne     scanchar
  177.  
  178. synerr:  mov     dx,offset syntax
  179.          call    strout
  180. errinit: stc
  181.          jmp     error
  182.  
  183. getdrive:
  184.          lodsb
  185.          cmp     al,'D'
  186.          je      ok1
  187.          cmp     al,'d'
  188.          jne     synerr
  189. ok1:     lodsb
  190.          cmp     al,':'
  191.          jne     synerr
  192.          lodsb
  193.          cmp     al,'0'
  194.          je      is_0
  195.          cmp     al,'1'
  196.          jne     synerr
  197.  
  198. is_1:    mov     si,0091h
  199.          mov     ax,2001h
  200.          jmp     short store_dr
  201. is_0:    mov     si,0090h
  202.          mov     ax,1200h
  203. store_dr:
  204.          push    cs
  205.          pop     ds
  206.          mov     bx,offset biosspeed
  207.          mov     word ptr [bx],si
  208.  
  209.          mov     di,offset ttlink
  210.          push    cs
  211.          pop     es
  212.          mov     es:[di+4],al
  213.          mov     es:[di+29h],ah
  214.          lds     bx,dword ptr cs:req_off
  215.          mov     al,[bx+16h]  ;  get logical dev.nr
  216.          mov     es:[di+5],al ;  and store
  217.          mov     cs:newdrive,al
  218.          add     al,'A'
  219.          mov     cs:dr_char,al
  220.  
  221.          mov     ax,801h     ;   parameters of new
  222.          push    cs          ;   drive passed to
  223.          pop     ds          ;   INT 2Fh 8(1)
  224.          mov     di,offset ttlink
  225.          int     2Fh
  226.  
  227.          lds     bx,dword ptr cs:req_off
  228.          mov     ah,1
  229.          mov     cs:countlog,ah
  230.          mov     [bx+0Dh],ah
  231.          mov     word ptr [bx+0Eh],offset good
  232.          mov     [bx+10h],cs
  233.          mov     word ptr [bx+12h],offset resbpb
  234.          mov     [bx+14h],cs
  235.          push    dx
  236.          mov     dx,offset mes_install
  237.          call    strout
  238.          pop     dx
  239.          jmp     good
  240.  
  241. mes_install db 'DRIVE720 V1.2: 720 kB-Drive installed.'
  242.          db      0Dh,0Ah
  243.          db      ' DEVICE = '
  244. dr_char  db      'D'
  245.          db      ': ', 0Ah, 0Dh, 24h
  246.  
  247. syntax   db      0Dh,0Ah
  248.          db      'DRIVE720: syntax error ',0Dh,0Ah
  249.          db      'usage: DEVICE-DRIVE720 /D:x '
  250.          db      ' {x is 0 or 1 for dirve A or B}'
  251.          db      0Dh,0Ah,24h
  252.  
  253. cseg     ends
  254.  
  255.          end
  256.  
  257. ;* ------------------------------------------------------- *
  258. ;*              Ende von DRIVE720.ASM                      *
  259. ;* ------------------------------------------------------- *
  260.