2017-02-09 12 views
0

현재 클러스터를 분할하고 결과를 추가하는 이유가 없습니다.
여기서 클러스터 포인터가 12 비트 각각의 코드FAT12 파일 시스템에서 새 클러스터를 찾기 위해 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   
+0

모든 것을 말하는'JNZ .ODD_CLUSTER' 다음에 자신의 코드에서 주석을 읽을 수 있습니다. – tofro

답변

1

이다. 바이트는 8 비트이므로 FAT 테이블 내의 클러스터 포인터의 바이트 오프셋은 cluster * 12/8 == cluster * 1.5입니다.
정수를 1.5로 곱하면 i + (i >> 1) 일 수 있습니다.이 코드는이 코드의 기능입니다.

+0

감사합니다. –