Skip to content

Commit a8b186e

Browse files
committed
[FREELDR] Adapt FAT helper code for the future base address change (reactos#7785)
1 parent 1bcc8f1 commit a8b186e

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

boot/freeldr/freeldr/arch/realmode/fathelp.inc

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
#define BiosCHSDriveSizeHigh 6
1515
#define BiosCHSDriveSizeLow 8
1616
#define BiosCHSDriveSize 8
17-
#define ReadSectorsOffset 10
18-
#define ReadClusterOffset 12
19-
#define PutCharsOffset 14
17+
#define ReadSectorsOffset 12
18+
#define ReadClusterOffset 16
19+
#define PutCharsOffset 20
20+
21+
#define ReadSectors dword ptr ss:[bp-ReadSectorsOffset]
22+
#define ReadCluster dword ptr ss:[bp-ReadClusterOffset]
23+
#define PutChars dword ptr ss:[bp-PutCharsOffset]
2024

2125
#define OEMName 3
2226
#define BytesPerSector 11
@@ -65,8 +69,8 @@ FatHelperEntryPoint:
6569
push ax
6670

6771
/* Display "Loading FreeLoader..." message */
68-
mov si, offset msgLoading
69-
call word ptr [bp-PutCharsOffset]
72+
mov si, offset msgLoading - FREELDR_BASE
73+
call CS_PutChars
7074

7175
call ReadFatIntoMemory
7276

@@ -92,7 +96,7 @@ LoadFile3:
9296
push ax
9397
xor bx,bx // Load ROSLDR starting at 0000:8000h
9498
push es
95-
call word ptr [bp-ReadClusterOffset]
99+
call ReadCluster
96100
pop es
97101

98102
xor bx,bx
@@ -133,7 +137,7 @@ ReadFatIntoMemory:
133137
mov bx, HEX(7000)
134138
mov es,bx
135139
xor bx,bx
136-
call word ptr [bp-ReadSectorsOffset]
140+
call ReadSectors
137141
ret
138142

139143

@@ -216,6 +220,22 @@ IsFat12_2:
216220
IsFat12_Done:
217221
ret
218222

223+
CS_PutChars:
224+
/* Save necessary registers */
225+
push ax
226+
push ds
227+
228+
/* Prepare ds before PutChars call */
229+
mov ax, cs
230+
mov ds, ax
231+
232+
/* Display the message */
233+
call PutChars
234+
235+
/* Restore necessary registers and return */
236+
pop ds
237+
pop ax
238+
ret
219239

220240
msgLoading:
221241
.ascii "Loading FreeLoader...", CR, LF, NUL

0 commit comments

Comments
 (0)