无法理解如何索引FAT表以在FAT12文件系统中查找新群集

时间:2017-02-09 17:20:37

标签: assembly fat

我无法理解为什么我们将当前群集划分并将结果添加到自身 这是代码

mov     ax, WORD [cluster]  ; current cluster

mov     cx, ax              ; copy current cluster 

mov     dx, ax              ; copy current cluster

 shr     dx, 0x0001          ; divide by two 

add     cx, dx              ; sum for (3/2) 

mov     bx, 0x0200          ; location of FAT in memory 

add     bx, cx              ; index into FAT 

mov  dx, WORD [bx]       ; read two bytes from FAT 

test    ax, 0x0001 

jnz     .ODD_CLUSTER ; Remember that each entry in the FAT is a 12 but value. If it represents ; a cluster (0x002 through 0xFEF) then we only want to get those 12 bits ; that represent the next cluster    

  .EVEN_CLUSTER:          
 and     dx, 0000111111111111b      ; take low twelve bits       
   jmp     .DONE 

  .ODD_CLUSTER:        
   shr     dx, 0x0004                 ; take high twelve bits     

.DONE:          
    mov     WORD [cluster], dx         ; store new cluster       
    cmp     dx, 0x0FF0                 ; test for end of file           

1 个答案:

答案 0 :(得分:1)

群集指针各为12位。一个字节是8位,因此FAT表中簇指针的字节偏移量为Items == cluster * 12/8
要将整数乘以1.5,您可以执行cluster * 1.5,这是此代码的作用。