home *** CD-ROM | disk | FTP | other *** search
/ PC Press 1997 July / Sezamfile97_1.iso / msdos / utility / sdf105.arj / FAT.ASM < prev    next >
Assembly Source File  |  1993-08-26  |  1KB  |  90 lines

  1. ;; ╔════════════════════════╗
  2. ;; ║   23/08/1993 - mjova   ║
  3. ;; ╚════════════════════════╝
  4.  
  5. locals
  6. .model large
  7.  
  8.  
  9. extrn    _FAT:DWORD;
  10.  
  11. .code
  12.  
  13.  
  14. ; ------------------------------------------------------------
  15. ; finds next sector
  16.         public c fat12
  17. fat12                proc c returns nextclu:word
  18.                     arg cluster:word
  19.  
  20.                     mov dx, 0
  21.         
  22.                     mov ax, cluster
  23.                     and ax, 0fffh
  24.                     cmp ax, 0ff0h
  25.                     jae @@EndCluster
  26.                     mov cx, ax
  27.                     and cx, 1
  28.                     shr ax, 1        ; /2
  29.  
  30.                     mov bx, ax
  31.                     add ax, ax
  32.                     add ax, bx        ; *3
  33.  
  34.                     rcr dx, 4        ; rcl 1
  35.                     add ax, cx
  36.  
  37.                     mov bx, WORD ptr [_FAT+2]
  38.                     add bx, dx
  39.                     mov es, bx
  40.  
  41.                     mov bx, ax
  42.                     mov ax, WORD ptr es:[bx]
  43.  
  44.                     mov bx, cluster
  45.                     and bx, 1
  46.                     jz @@even
  47.                     shr ax, 4
  48.                     jmp @@ChkEnd
  49. @@even:            and ax, 0fffh
  50. @@ChkEnd:        cmp ax, 0ff0h
  51.                     jae @@EndCluster
  52.                     ret
  53. @@EndCluster:    mov ax, 0ffffh
  54.                     ret
  55.  
  56. fat12                endp
  57.  
  58.  
  59.  
  60.  
  61. ; ------------------------------------------------------------
  62.         public c fat16
  63. fat16                proc c returns nextclu:word
  64.                     arg cluster:word
  65.  
  66.                     mov ax, cluster
  67.                     cmp ax, 0fff0h
  68.                     jae @@EndCluster
  69.                     add ax, ax
  70.                     mov dx, 0
  71.                     rcr dx, 4        ; rcl 1
  72.  
  73.                     mov bx, WORD ptr [_FAT+2]
  74.                     add bx, dx
  75.                     mov es, bx
  76.  
  77.                     mov bx, ax
  78.                     mov ax, WORD ptr es:[bx]
  79.  
  80.                     cmp ax, 0fff0h
  81.                     jae @@EndCluster
  82.                     ret
  83. @@EndCluster:    mov ax, 0ffffh
  84.                     ret
  85.  
  86. fat16                endp
  87.  
  88.  
  89.                     end
  90.