somewhat of a cludge, but added a macro to save all caller saved regs
This commit is contained in:
@@ -39,3 +39,19 @@
|
||||
pop bp
|
||||
%endmacro
|
||||
%endif
|
||||
|
||||
%ifnmacro __CDECL16_CALLER_SAVE
|
||||
%macro __CDECL16_CALLER_SAVE 0
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
%endmacro
|
||||
%endif
|
||||
|
||||
%ifnmacro __CDECL16_CALLER_RESTORE
|
||||
%macro __CDECL16_CALLER_RESTORE 0
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
%endmacro
|
||||
%endif
|
||||
@@ -91,6 +91,8 @@ SearchFATDIR:
|
||||
mov eax, [fat32_ebpb + FAT32_ebpb_t.root_dir_cluster_32]
|
||||
mov dword [fat32_state + FAT32_State_t.active_dir_cluster_32], eax
|
||||
|
||||
__CDECL16_CALLER_SAVE
|
||||
|
||||
push dword eax ; cluster
|
||||
lea ax, [dir_buffer]
|
||||
push ax ; offset
|
||||
@@ -99,16 +101,20 @@ SearchFATDIR:
|
||||
call ReadFATCluster ; uint8_t ReadFATCluster(uint16_t seg, uint16_t offset, uint32_t cluster)
|
||||
add sp, 0x8
|
||||
|
||||
__CDECL16_CALLER_RESTORE
|
||||
|
||||
lea si, [dir_buffer]
|
||||
jmp SearchFATDIR.empty_dir_entry
|
||||
|
||||
.load_next_dir:
|
||||
; if eax >= 0x0FFFFFF8 then there are no more clusters (end of chain)
|
||||
; if eax == 0x0FFFFFF7 then this is a cluster that is marked as bad
|
||||
__CDECL16_CALLER_SAVE
|
||||
mov eax, dword [fat32_state + FAT32_State_t.active_dir_cluster_32]
|
||||
push dword eax
|
||||
call NextCluster ; uint32_t NextCluster(uint32_t active_cluster);
|
||||
add sp, 0x4
|
||||
__CDECL16_CALLER_RESTORE
|
||||
|
||||
cmp eax, 0x0fff_fff7
|
||||
jb SearchFATDIR.load_next_dir_next_OK
|
||||
@@ -116,15 +122,18 @@ SearchFATDIR:
|
||||
|
||||
.load_next_dir_next_OK:
|
||||
; load 512 bytes of directory entries from data sector
|
||||
__CDECL16_CALLER_SAVE
|
||||
mov eax, [fat32_state + FAT32_State_t.active_dir_cluster_32]
|
||||
push dword eax ; cluster
|
||||
|
||||
push dword eax
|
||||
lea ax, [dir_buffer] ; cluster
|
||||
lea ax, [dir_buffer]
|
||||
push ax ; offset
|
||||
|
||||
xor ax, ax
|
||||
push ax ; segment
|
||||
call ReadFATCluster ; uint8_t ReadFATCluster(uint16_t seg, uint16_t offset, uint32_t cluster)
|
||||
sub sp, 0x8
|
||||
__CDECL16_CALLER_RESTORE
|
||||
|
||||
lea si, [dir_buffer]
|
||||
.empty_dir_entry:
|
||||
@@ -181,7 +190,7 @@ SearchFATDIR:
|
||||
.endp:
|
||||
__CDECL16_EXIT
|
||||
ret
|
||||
|
||||
; BUG: this function needs review
|
||||
; uint32_t NextCluster(uint32_t active_cluster);
|
||||
; if eax >= 0x0FFFFFF8 then there are no more clusters (end of chain)
|
||||
; if eax == 0x0FFFFFF7 then this is a cluster that is marked as bad
|
||||
@@ -232,6 +241,7 @@ NextCluster:
|
||||
add eax, ecx ; fat_sector + first_fat_sector
|
||||
mov dword [si + FAT32_NextClusterData_t.fat_sector], eax
|
||||
.load_fat_table:
|
||||
__CDECL16_CALLER_SAVE
|
||||
movzx ax, [bp - 2]
|
||||
push ax
|
||||
|
||||
@@ -249,6 +259,7 @@ NextCluster:
|
||||
push ax
|
||||
call read_disk_raw
|
||||
add sp, 0xC
|
||||
__CDECL16_CALLER_RESTORE
|
||||
; uint8_t read_stage2_raw(uint16_t buf_segment, uint16_t buf_offset,
|
||||
; uint32_t lba,
|
||||
; uint16_t count, uint16_t drive_num)
|
||||
@@ -281,6 +292,7 @@ ALIGN 4, db 0x90
|
||||
ReadFATCluster:
|
||||
__CDECL16_ENTRY
|
||||
.func:
|
||||
__CDECL16_CALLER_SAVE
|
||||
mov bx, [boot_drive_ptr]
|
||||
mov ax, [bx + 0]
|
||||
mov byte [bp - 2], al ; save boot drive as a local for easy access
|
||||
@@ -290,7 +302,9 @@ ReadFATCluster:
|
||||
call ClusterToLBA ; uint32_t ClusterToLBA(uint32_t cluster)
|
||||
add sp, 0x4 ; eax == LBA
|
||||
mov dword [bp - 6], eax
|
||||
__CDECL16_CALLER_RESTORE
|
||||
|
||||
__CDECL16_CALLER_SAVE
|
||||
movzx ax, [bp - 2]
|
||||
push ax
|
||||
|
||||
@@ -305,8 +319,12 @@ ReadFATCluster:
|
||||
|
||||
xor ax, ax
|
||||
push ax
|
||||
; uint8_t read_stage2_raw(uint16_t buf_segment, uint16_t buf_offset,
|
||||
; uint32_t lba,
|
||||
; uint16_t count, uint16_t drive_num)
|
||||
call read_disk_raw
|
||||
add sp, 0xC
|
||||
__CDECL16_CALLER_RESTORE
|
||||
.endp:
|
||||
__CDECL16_EXIT
|
||||
ret
|
||||
|
||||
Reference in New Issue
Block a user