在FAT12中计算下一个簇

时间:2014-03-03 21:39:04

标签: assembly

这是来自:BrokenThorn

的代码
; compute next cluster

          mov     ax, WORD [cluster]  ; identify current cluster from FAT

     ; is the cluster odd or even? Just divide it by 2 and test!

          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

我不明白add cx, dx的逻辑  添加CX和DX的目的是什么?

是否有图表可以看到这个?

1 个答案:

答案 0 :(得分:1)

FAT元素长度为12位,因此必须将元素索引乘以1.5才能获得字节偏移量