Code: Select all
mov dx, word [dword eax + FAT_OFFSET]
Code: Select all
mov dx, word [dword FAT_OFFSET + 8]
I was told that in some machines 32 bits addresses cannot be accessed unless unreal mode is enabled but since sometimes it works I don't think this is the case.
Obviously, only that one line of code cannot underline any error so I'm posting also the function that includes that line. To give you some more context I'm also linking the GitHub repo folder that contains this code. It is in boot/include/fat16.inc and the functions of this file produces this error when they are called from boot/include/fat16_ext.inc which contains some functions called in boot/loader.asm around line 213.
I spent a few days trying to track this error but this is all I could find. I hope is an easy solution.
Code: Select all
;*********************************************;
; Read the current selected cluster in memory ;
; Parameters: ;
; ebx => Buffer to load file to ;
;*********************************************;
LoadNextCluster:
; zero out registers for calculations
xor ecx, ecx
xor dx, dx
; convert the cluster in lba
mov ax, word [cluster]
sub ax, 2
mov dl, byte [bpb_SectorsPerCluster]
mul dx
xchg cx, ax
add ecx, dword [first_cluster_sector]
; sets the others parameters and read the disk
mov dl, byte [bpb_DriveNumber]
mov al, byte [bpb_SectorsPerCluster]
call ReadSectorsLBA
; get next cluster from fat table
xor eax, eax
mov ax, word [cluster]
mov dx, 2
mul dx ; since fat table is an array of words (2 byte)
mov dx, word [dword eax + FAT_OFFSET]
mov word [cluster], dx
ret