2017-02-09 55 views
0

我不明白爲什麼我們將當前集羣和結果添加到自身。
下面是代碼無法理解如何索引FAT表來查找FAT12文件系統中的新集羣

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   
+0

您可能需要在'JNZ .ODD_CLUSTER'之後的自己的代碼中讀取註釋。 – tofro

回答

1

簇指針是每個12個比特。一個字節是8位,因此FAT表中的簇指針的字節偏移量爲cluster * 12/8 == cluster * 1.5
要將整數乘以1.5,您可以執行i + (i >> 1),這是此代碼的作用。

+0

謝謝,我明白了 –