Question

This is code from: 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

I don't understand the logic for add cx, dx What is the purpose of adding CX and DX?

Is there a diagram where I can visualize this?

Was it helpful?

Solution

FAT element is 12 bits long, so you must multiply element index by 1.5 to get byte offset

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top