wok-current rev 24478
Typos in BootProg
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Feb 18 10:06:45 2022 +0000 (2022-02-18) |
parents | 73cd26fd8ff2 |
children | d211771a0500 |
files | BootProg/receipt BootProg/stuff/boot16.asm BootProg/stuff/boot32.asm BootProg/stuff/bootex.asm |
line diff
1.1 --- a/BootProg/receipt Fri Feb 18 10:50:23 2022 +0100 1.2 +++ b/BootProg/receipt Fri Feb 18 10:06:45 2022 +0000 1.3 @@ -16,7 +16,7 @@ 1.4 compile_rules() 1.5 { 1.6 for i in bootex boot16 boot32 ; do 1.7 - nasm $stuff/$i.asm -f bin $i.bin -l $i.lst 1.8 + nasm $stuff/$i.asm -f bin -o $i.bin -l $i.lst 1.9 done 1.10 sed '1,/^exit 1/!d' $stuff/bootprog.sh > bootprog 1.11 tar czf - boot16.bin boot32.bin bootex.bin > set.tar.gz
2.1 --- a/BootProg/stuff/boot16.asm Fri Feb 18 10:50:23 2022 +0100 2.2 +++ b/BootProg/stuff/boot16.asm Fri Feb 18 10:06:45 2022 +0000 2.3 @@ -28,8 +28,8 @@ 2.4 ;; ;; 2.5 ;; Known Limitations: ;; 2.6 ;; ~~~~~~~~~~~~~~~~~~ ;; 2.7 -;; - Works only on the 1st MBR partition which must be a PRI DOS partition ;; 2.8 -;; with FAT12 (File System ID: 1) and FAT16 (File System ID: 4, 6) ;; 2.9 +;; - Works only on the 1st MBR partition which must be a DOS partition ;; 2.10 +;; with FAT12 (File System ID: 1) or FAT16 (File System ID: 4, 6) ;; 2.11 ;; ;; 2.12 ;; ;; 2.13 ;; Known Bugs: ;; 2.14 @@ -556,10 +556,10 @@ 2.15 2.16 Error: 2.17 pop si 2.18 + 2.19 +PutStr: 2.20 mov ah, 0Eh 2.21 mov bl, 7 2.22 - 2.23 -PutStr: 2.24 lodsb 2.25 int 10h 2.26 cmp al, "."
3.1 --- a/BootProg/stuff/boot32.asm Fri Feb 18 10:50:23 2022 +0100 3.2 +++ b/BootProg/stuff/boot32.asm Fri Feb 18 10:06:45 2022 +0000 3.3 @@ -11,12 +11,12 @@ 3.4 ;; ;; 3.5 ;; Features: ;; 3.6 ;; ~~~~~~~~~ ;; 3.7 -;; - FAT32 supported using BIOS int 13h function 42h or 02h. ;; 3.8 +;; - FAT32 supported using BIOS int 13h function 42h (IOW, it will only ;; 3.9 +;; work with modern BIOSes supporting HDDs bigger than 8 GB) ;; 3.10 ;; ;; 3.11 ;; - Loads a 16-bit executable file in the MS-DOS .COM or .EXE format ;; 3.12 ;; from the root directory of a disk and transfers control to it ;; 3.13 ;; (the "ProgramName" variable holds the name of the file to be loaded) ;; 3.14 -;; Its maximum size can be up to 636KB without Extended BIOS Data area. ;; 3.15 ;; ;; 3.16 ;; - Prints an error if the file isn't found or couldn't be read ;; 3.17 ;; ("File not found" or "Read error") ;; 3.18 @@ -26,7 +26,7 @@ 3.19 ;; ;; 3.20 ;; Known Limitations: ;; 3.21 ;; ~~~~~~~~~~~~~~~~~~ ;; 3.22 -;; - Works only on the 1st MBR partition which must be a PRI DOS partition ;; 3.23 +;; - Works only on the 1st MBR partition which must be a DOS partition ;; 3.24 ;; with FAT32 (File System ID: 0Bh,0Ch) ;; 3.25 ;; ;; 3.26 ;; ;; 3.27 @@ -54,10 +54,10 @@ 3.28 ;; | Loaded Image | ;; 3.29 ;; +------------------------+ nnnnnH ;; 3.30 ;; | Available Memory | ;; 3.31 -;; +------------------------+ A0000H - 2KB ;; 3.32 +;; +------------------------+ A0000H - 512 - 2KB ;; 3.33 +;; | 2KB Boot Stack | ;; 3.34 +;; +------------------------+ A0000H - 512 ;; 3.35 ;; | Boot Sector | ;; 3.36 -;; +------------------------+ A0000H - 1.5KB ;; 3.37 -;; | 1.5KB Boot Stack | ;; 3.38 ;; +------------------------+ A0000H ;; 3.39 ;; | Video RAM | ;; 3.40 ;; ;; 3.41 @@ -81,14 +81,10 @@ 3.42 ;; ;; 3.43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.44 3.45 -%define bx(label) bx+label-boot 3.46 - 3.47 [BITS 16] 3.48 -[CPU 8086] 3.49 3.50 ? equ 0 3.51 -ImageLoadSeg equ 60h 3.52 -StackSize equ 1536 3.53 +ImageLoadSeg equ 60h ; <=07Fh because of "push byte ImageLoadSeg" instructions 3.54 3.55 [SECTION .text] 3.56 [ORG 0] 3.57 @@ -97,7 +93,6 @@ 3.58 ;; Boot sector starts here ;; 3.59 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.60 3.61 -boot: 3.62 jmp short start ; MS-DOS/Windows checks for this jump 3.63 nop 3.64 bsOemName DB "BootProg" ; 0x03 3.65 @@ -157,97 +152,102 @@ 3.66 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.67 3.68 int 12h ; get conventional memory size (in KBs) 3.69 - mov cx, 106h 3.70 - dec ax 3.71 - dec ax ; reserve 2K bytes for the code and the stack 3.72 - shl ax, cl ; and convert it to 16-byte paragraphs 3.73 + shl ax, 6 ; and convert it to 16-byte paragraphs 3.74 3.75 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.76 ;; Reserve memory for the boot sector and its stack ;; 3.77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.78 3.79 - mov es, ax ; cs:0 = ds:0 = ss:0 -> top - 512 - StackSize 3.80 - mov ss, ax 3.81 - mov sp, 512+StackSize ; bytes 0-511 are reserved for the boot code 3.82 + sub ax, 512 / 16 ; reserve 512 bytes for the boot sector code 3.83 + mov es, ax ; es:0 -> top - 512 3.84 + 3.85 + sub ax, 2048 / 16 ; reserve 2048 bytes for the stack 3.86 + mov ss, ax ; ss:0 -> top - 512 - 2048 3.87 + mov sp, 2048 ; 2048 bytes for the stack 3.88 3.89 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.90 ;; Copy ourselves to top of memory ;; 3.91 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.92 3.93 + mov cx, 256 3.94 mov si, 7C00h 3.95 xor di, di 3.96 mov ds, di 3.97 - rep movsw ; move 512 bytes (+ 12) 3.98 + rep movsw 3.99 3.100 ;;;;;;;;;;;;;;;;;;;;;; 3.101 ;; Jump to the copy ;; 3.102 ;;;;;;;;;;;;;;;;;;;;;; 3.103 3.104 push es 3.105 - mov cl, main 3.106 - push cx 3.107 + push byte main 3.108 retf 3.109 3.110 main: 3.111 push cs 3.112 pop ds 3.113 3.114 - xor bx, bx 3.115 - mov [bx], dx ; store BIOS boot drive number 3.116 + mov [bsDriveNumber], dl ; store BIOS boot drive number 3.117 3.118 - and byte [bx(bsRootDirectoryClusterNo)+3], 0Fh ; mask cluster value 3.119 - les si, [bx(bsRootDirectoryClusterNo)] ; si2:si=cluster # of root dir 3.120 - mov si2, es 3.121 - 3.122 - mov cl, ImageLoadSeg 3.123 - mov es, cx 3.124 + and byte [bsRootDirectoryClusterNo+3], 0Fh ; mask cluster value 3.125 + mov esi, [bsRootDirectoryClusterNo] ; esi=cluster # of root dir 3.126 3.127 RootDirReadContinue: 3.128 - call ReadCluster ; read one sector of root dir; clear ch 3.129 - pushf ; save carry="not last sector" flag 3.130 + push byte ImageLoadSeg 3.131 + pop es 3.132 + xor bx, bx 3.133 + push es 3.134 + call ReadCluster ; read one cluster of root dir 3.135 + pop es 3.136 + pushad ; save esi=next cluster # of root dir 3.137 + ; save eax=next sector # of root dir 3.138 + pushf ; save carry="not last cluster" flag 3.139 3.140 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.141 ;; Look for the COM/EXE file to load and run ;; 3.142 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.143 3.144 xor di, di ; es:di -> root entries array 3.145 + mov si, ProgramName ; ds:si -> program name 3.146 3.147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.148 -;; Looks for the file/dir ProgramName ;; 3.149 +;; Looks for a file/dir by its name ;; 3.150 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.151 -;; Input: ES:DI -> root directory array ;; 3.152 -;; BP = paragraphs count ;; 3.153 +;; Input: DS:SI -> file name (11 chars) ;; 3.154 +;; ES:DI -> root directory array ;; 3.155 +;; DX = number of root entries ;; 3.156 ;; Output: ESI = cluster number ;; 3.157 -;; DI = file paragraph count ;; 3.158 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.159 3.160 +FindName: 3.161 + mov cx, 11 3.162 FindNameCycle: 3.163 - cmp byte [es:di], bh 3.164 - je FindNameFailed ; end of root directory (NULL entry found) 3.165 - push si 3.166 - push di 3.167 - mov cl, 11 3.168 - mov si, ProgramName ; ds:si -> program name 3.169 + cmp byte [es:di], ch 3.170 + je ErrFind ; end of root directory (NULL entry found) 3.171 +FindNameNotEnd: 3.172 + pusha 3.173 repe cmpsb 3.174 - pop di 3.175 - pop si 3.176 + popa 3.177 je FindNameFound 3.178 - add di, 32 ; max cluster = 64k 3.179 + add di, 32 3.180 dec bp 3.181 dec bp 3.182 jnz FindNameCycle ; next root entry 3.183 - popf ; restore carry="not last sector" flag 3.184 + popf ; restore carry="not last cluster" flag 3.185 + ; restore eax=next sector # of root dir 3.186 + popad ; restore esi=next cluster # of root dir 3.187 jc RootDirReadContinue ; continue to the next root dir cluster 3.188 -FindNameFailed: ; end of root directory (dir end reached) 3.189 - call Error 3.190 +ErrFind: 3.191 + call Error ; end of root directory (dir end reached) 3.192 db "File not found." 3.193 FindNameFound: 3.194 - mov si2, word [es:di+14h] 3.195 - mov si, word [es:di+1Ah] ; si2:si = cluster no; cx = 0. 3.196 + push word [es:di+14h] 3.197 + push word [es:di+1Ah] 3.198 + pop esi ; esi = cluster no. cx = 0 3.199 3.200 -============== 3.201 dec dword [es:di+1Ch] ; load ((n - 1)/256)*16 +1 paragraphs 3.202 - imul di, [es:di+1Dh], 16 ; file size in paragraphs (full pages) 3.203 + imul di, [es:di+1Ch+1], 16 ; file size in paragraphs (full pages) 3.204 + xor cx, cx 3.205 3.206 ;;;;;;;;;;;;;;;;;;;;;;;;;; 3.207 ;; Load the entire file ;; 3.208 @@ -256,33 +256,32 @@ 3.209 push es 3.210 FileReadContinue: 3.211 push di 3.212 - call ReadCluster ; read one more sector 3.213 + call ReadCluster ; read one cluster of root dir 3.214 mov di, es 3.215 - add di, bp ; adjust segment for next sector 3.216 - mov es, di ; es:0 updated 3.217 + add di, bp 3.218 + mov es, di ; es:bx updated 3.219 pop di 3.220 + 3.221 sub di, bp 3.222 jae FileReadContinue 3.223 -============== 3.224 pop bp 3.225 3.226 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.227 ;; Type detection, .COM or .EXE? ;; 3.228 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.229 3.230 - mov dl, [bx] ; pass the BIOS boot drive 3.231 mov ds, bp ; bp=ds=seg the file is loaded to 3.232 - 3.233 add bp, [bx+08h] ; bp = image base 3.234 mov ax, [bx+06h] ; ax = reloc items 3.235 mov di, [bx+18h] ; di = reloc table pointer 3.236 3.237 cmp word [bx], 5A4Dh ; "MZ" signature? 3.238 + 3.239 je RelocateEXE ; yes, it's an EXE program 3.240 3.241 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.242 ;; Setup and run a .COM program ;; 3.243 -;; Set CS=DS=ES=SS SP=0 IP=100h ;; 3.244 +;; Set CS=DS=ES=SP SP=0 IP=100h ;; 3.245 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.246 3.247 mov bp, ImageLoadSeg-10h ; "org 100h" stuff :) 3.248 @@ -302,8 +301,7 @@ 3.249 add [di+2], bp ; item seg (abs) 3.250 les si, [di] ; si = item ofs, es = item seg 3.251 add [es:si], bp ; fixup 3.252 - scasw ; di += 2 3.253 - scasw ; point to next entry 3.254 + add di, 4 ; point to next entry 3.255 3.256 RelocateEXE: 3.257 dec ax ; 32768 max (128KB table) 3.258 @@ -339,164 +337,105 @@ 3.259 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.260 retf 3.261 3.262 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.263 -;; Reads a FAT32 cluster ;; 3.264 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.265 -;; Input: ES:0 -> buffer ;; 3.266 -;; EDX:EAX = sector no ;; 3.267 -;; CX = sectors to load ;; 3.268 -;; ESI = cluster no ;; 3.269 -;; BX = 0 ;; 3.270 -;; Output: ES:0 -> buffer ;; 3.271 -;; EDX:EAX = sector no ;; 3.272 -;; CX = sectors to load ;; 3.273 -;; ESI = next cluster ;; 3.274 -;; BX = 0 ;; 3.275 -;; CH = 0 ;; 3.276 -;; BP = para/sector ;; 3.277 -;; C=0 for last sector ;; 3.278 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.279 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.280 +;; Reads a FAT32 cluster ;; 3.281 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.282 +;; Inout: ES:BX -> buffer ;; 3.283 +;; ESI = cluster no ;; 3.284 +;; Output: ESI = next cluster ;; 3.285 +;; ES:BX -> next addr ;; 3.286 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.287 3.288 ReadCluster: 3.289 -============== 3.290 - mov bp, word [bx(bpbBytesPerSector)] 3.291 - shr bp, 4 ; paragraphs per sector 3.292 inc cx 3.293 - add ax, 1 ; adjust LBA for next sector 3.294 -? adc dx, bx 3.295 - loop ReadSectorLBANext 3.296 + loop ReadSectorLBA 3.297 3.298 - imul ax, bp, 2 3.299 - cwde ; eax=# of FAT32 entries per sector 3.300 - lea edi, [esi-2] ; edi=cluster #-2 3.301 + mov ax, [bpbBytesPerSector] 3.302 + push ax 3.303 + shr ax, 2 ; ax=# of FAT32 entries per sector 3.304 + cwde 3.305 + lea ebp, [esi-2] ; esi=cluster # 3.306 xchg eax, esi 3.307 cdq 3.308 - div esi ; eax=FAT sector #, edx=entry # in sector < 128 3.309 + div esi ; eax=FAT sector #, edx=entry # in sector 3.310 3.311 - imul si, dx, 4 ; si=entry # offset in sector 3.312 + imul si, dx, 4 ; si=entry # in sector 3.313 + call ReadSectorLBAabsolute ; read 1 FAT32 sector 3.314 3.315 - call ReadSectorLBA ; read 1 FAT32 sector 3.316 + and byte [es:si+3], 0Fh ; mask cluster value 3.317 + mov esi, [es:si] ; esi=next cluster # 3.318 3.319 - mov si2, 0FFFh 3.320 - and si2, [es:si+2] ; mask cluster value 3.321 - mov si, [es:si] ; si2:si=next cluster # 3.322 + xchg eax, ebp 3.323 + movzx ecx, byte [bpbSectorsPerCluster] 3.324 + mul ecx 3.325 + xchg eax, ebp 3.326 3.327 - movzx eax, byte [bx(bpbNumberOfFATs)] 3.328 - mul dword [bx(bsSectorsPerFAT32)] ; edx < 256 3.329 + movzx eax, byte [bpbNumberOfFATs] 3.330 + mul dword [bsSectorsPerFAT32] 3.331 3.332 - xchg eax, edi ; get cluster #-2 ; save data offset 3.333 + add eax, ebp 3.334 3.335 - movzx ecx, byte [bx(bpbSectorsPerCluster)] 3.336 - mul ecx 3.337 + pop bp ; [bpbBytesPerSector] 3.338 + shr bp, 4 ; bp = paragraphs per sector 3.339 3.340 - add eax, edi ; sector # relative to FAT32 3.341 +ReadSectorLBAabsolute: 3.342 + movzx edx, word [bpbReservedSectors] 3.343 + add eax, edx 3.344 + add eax, [bpbHiddenSectors] 3.345 3.346 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.347 -;; Reads a sector using BIOS Int 13h ;; 3.348 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.349 -;; Input: ES:0 -> buffer address ;; 3.350 -;; EAX = LBA (FAT based) ;; 3.351 -;; BX = 0 ;; 3.352 -;; CX = sector count ;; 3.353 -;; Output: ES:0 -> buffer address ;; 3.354 -;; EDX:EAX = absolute LBA ;; 3.355 -;; BX = 0 ;; 3.356 -;; CX = next sector count ;; 3.357 -;; BP = paragraphs/sector ;; 3.358 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.359 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.360 +;; Reads a sector using BIOS Int 13h fn 42h ;; 3.361 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.362 +;; Input: EAX = LBA ;; 3.363 +;; CX = sector count ;; 3.364 +;; ES:BX -> buffer address ;; 3.365 +;; Output: CF = 0 if no more sectors ;; 3.366 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.367 3.368 ReadSectorLBA: 3.369 - 3.370 - mov dx, word [bx(bpbReservedSectors)] 3.371 - add eax, edx 3.372 - mov dx, bx 3.373 - adc dx, bx 3.374 - add eax, [bx(bpbHiddenSectors)] 3.375 - 3.376 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.377 -;; Input: ES:0 -> buffer address ;; 3.378 -;; EDX:EAX = absolute LBA ;; 3.379 -;; BX = 0 ;; 3.380 -;; CX = sector count ;; 3.381 -;; Output: ES:0 -> buffer address ;; 3.382 -;; EDX:EAX = absolute LBA ;; 3.383 -;; BX = 0 ;; 3.384 -;; CX = next sector count ;; 3.385 -;; BP = paragraphs/sector ;; 3.386 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.387 - 3.388 -ReadSectorLBANext: 3.389 - 3.390 - adc dx, bx ; FAT32 partition can start up to 2TB 3.391 - 3.392 + mov dl, [bsDriveNumber] ; restore BIOS boot drive number 3.393 pusha 3.394 3.395 - push edx ; 33-bit LBA only: up to 4TB disks 3.396 - push eax ; 32-bit LBA: up to 2TB FAT32 partition start 3.397 + push bx 3.398 + push bx ; 32-bit LBA only: up to 2TB disks 3.399 + push eax 3.400 push es 3.401 push bx 3.402 - push byte 1 ; sector count word = 1 3.403 - push byte 16 ; packet size byte = 16, reserved byte = 0 3.404 - 3.405 - push eax 3.406 - pop cx ; low LBA 3.407 - pop ax ; high LBA, dx=0 (<2TB) 3.408 - div word [bx(bpbSectorsPerTrack)] ; up to 8GB disks 3.409 + push byte 1 ; sector count word = 1 3.410 + mov cx, 16 ; retry count 3.411 + push cx ; packet size byte = 16, reserved byte = 0 3.412 3.413 - xchg ax, cx ; restore low LBA, save high LBA / SPT 3.414 - div word [bx(bpbSectorsPerTrack)] 3.415 - ; ax = LBA / SPT 3.416 - ; dx = LBA % SPT = sector - 1 3.417 - inc dx 3.418 +ReadSectorRetry: 3.419 + mov ah, 42h ; ah = 42h = extended read function no. 3.420 + mov si, sp 3.421 + push ss 3.422 + pop ds 3.423 + int 13h ; extended read sectors (DL, DS:SI) 3.424 + push cs 3.425 + pop ds 3.426 + jnc ReadSuccess ; CF = 0 if no error 3.427 3.428 - xchg cx, dx ; restore high LBA / SPT, save sector no. 3.429 - div word [bx(bpbHeadsPerCylinder)] 3.430 - ; ax = (LBA / SPT) / HPC = cylinder 3.431 - ; dx = (LBA / SPT) % HPC = head 3.432 - shl ah, 6 3.433 - mov ch, al 3.434 - ; ch = LSB 0...7 of cylinder no. 3.435 - or cl, ah 3.436 - ; cl = MSB 8...9 of cylinder no. + sector no. 3.437 - mov dh, dl 3.438 - ; dh = head no. 3.439 - 3.440 -ReadSectorLBARetry: 3.441 - mov dl, [bx] 3.442 - ; dl = drive no. 3.443 - mov si, sp 3.444 - mov ah, 42h ; ah = 42h = extended read function no. 3.445 - int 13h ; extended read sectors (DL, DS:SI) 3.446 - jnc ReadSectorNextSegment 3.447 - 3.448 -ReadSectorCHSRetry: 3.449 - mov ax, 201h ; al = sector count = 1 3.450 - ; ah = 2 = read function no. 3.451 - int 13h ; read sectors (AL, CX, DX, ES:BX) 3.452 - jnc ReadSectorNextSegment 3.453 - 3.454 - cbw ; ah = 0 = reset function 3.455 + xor ax, ax ; ah = 0 = reset function 3.456 int 13h ; reset drive (DL) 3.457 3.458 - dec bp 3.459 - jnz ReadSectorLBARetry 3.460 - 3.461 + loop ReadSectorRetry ; extra attempt 3.462 call Error 3.463 db "Read error." 3.464 3.465 -ReadSectorNextSegment: 3.466 +ReadSuccess: 3.467 3.468 popa ; sp += 16 3.469 - popa ; restore real registers 3.470 -============== 3.471 + 3.472 + popa 3.473 + 3.474 + inc eax ; adjust LBA for next sector 3.475 + 3.476 stc 3.477 - loop ReadSectorDone 3.478 + loop ReadSectorNext 3.479 3.480 - cmp si2, 0FFFh 3.481 - jne ReadSectorDone 3.482 - cmp si, 0FFF8h ; carry=0 if last cluster, and carry=1 otherwise 3.483 + cmp esi, 0FFFFFF8h ; carry=0 if last cluster, and carry=1 otherwise 3.484 3.485 -ReadSectorDone: 3.486 +ReadSectorNext: 3.487 ret 3.488 3.489 ;;;;;;;;;;;;;;;;;;;;;;;;;; 3.490 @@ -505,24 +444,17 @@ 3.491 3.492 Error: 3.493 pop si 3.494 - mov dl, [bx] ; restore BIOS boot drive number 3.495 +puts: 3.496 mov ah, 0Eh 3.497 mov bl, 7 3.498 - 3.499 -PutStr: 3.500 lodsb 3.501 int 10h 3.502 - cmp al, "." 3.503 - jne PutStr 3.504 - 3.505 + cmp al, '.' 3.506 + jne puts 3.507 cbw 3.508 int 16h ; wait for a key... 3.509 int 19h ; bootstrap 3.510 3.511 -Stop: 3.512 - hlt 3.513 - jmp short Stop 3.514 - 3.515 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.516 ;; Fill free space with zeroes ;; 3.517 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4.1 --- a/BootProg/stuff/bootex.asm Fri Feb 18 10:50:23 2022 +0100 4.2 +++ b/BootProg/stuff/bootex.asm Fri Feb 18 10:06:45 2022 +0000 4.3 @@ -448,10 +448,10 @@ 4.4 Error: 4.5 pop si 4.6 mov dl, [bx] ; restore BIOS boot drive number 4.7 + 4.8 +PutStr: 4.9 mov ah, 0Eh 4.10 mov bl, 7 4.11 - 4.12 -PutStr: 4.13 lodsb 4.14 int 10h 4.15 cmp al, "."