wok view BootProg/stuff/boot16.asm @ rev 25452

BootProg: typos
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Sep 15 10:06:54 2022 +0000 (19 months ago)
parents 62d43c1b8453
children ec9531d04de1
line source
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; ;;
3 ;; "BootProg" Loader v 1.5 by Alexey Frunze (c) 2000-2015 ;;
4 ;; 2-clause BSD license. ;;
5 ;; ;;
6 ;; ;;
7 ;; How to Compile: ;;
8 ;; ~~~~~~~~~~~~~~~ ;;
9 ;; nasm boot16.asm -f bin -o boot16.bin ;;
10 ;; ;;
11 ;; ;;
12 ;; Features: ;;
13 ;; ~~~~~~~~~ ;;
14 ;; - FAT12 and FAT16 supported using BIOS int 13h function 42h or 02h. ;;
15 ;; ;;
16 ;; - Loads a 16-bit executable file in the MS-DOS .COM or .EXE format ;;
17 ;; from the root directory of a disk and transfers control to it ;;
18 ;; (the "ProgramName" variable holds the name of the file to be loaded) ;;
19 ;; Its maximum size can be up to 635KB without Extended BIOS Data area. ;;
20 ;; ;;
21 ;; - Prints an error if the file isn't found or couldn't be read ;;
22 ;; ("File not found" or "Read error") ;;
23 ;; and waits for a key to be pressed, then executes the Int 19h ;;
24 ;; instruction and lets the BIOS continue bootstrap. ;;
25 ;; ;;
26 ;; - cpu 8086 is supported ;;
27 ;; ;;
28 ;; ;;
29 ;; Known Bugs: ;;
30 ;; ~~~~~~~~~~~ ;;
31 ;; - All bugs are fixed as far as I know. The boot sector has been tested ;;
32 ;; on the following types of diskettes (FAT12): ;;
33 ;; - 360KB 5"25 ;;
34 ;; - 1.2MB 5"25 ;;
35 ;; - 1.44MB 3"5 ;;
36 ;; on my HDD (FAT16). ;;
37 ;; ;;
38 ;; ;;
39 ;; Memory Layout: ;;
40 ;; ~~~~~~~~~~~~~~ ;;
41 ;; The diagram below shows the typical memory layout. The actual location ;;
42 ;; of the boot sector and its stack may be lower than A0000H if the BIOS ;;
43 ;; reserves memory for its Extended BIOS Data Area just below A0000H and ;;
44 ;; reports less than 640 KB of RAM via its Int 12H function. ;;
45 ;; ;;
46 ;; physical address ;;
47 ;; +------------------------+ 00000H ;;
48 ;; | Interrupt Vector Table | ;;
49 ;; +------------------------+ 00400H ;;
50 ;; | BIOS Data Area | ;;
51 ;; +------------------------+ 00500H ;;
52 ;; | PrtScr Status / Unused | ;;
53 ;; +------------------------+ 00600H ;;
54 ;; | Loaded Image | ;;
55 ;; +------------------------+ nnnnnH ;;
56 ;; | Available Memory | ;;
57 ;; +------------------------+ A0000H - 512 - 3KB ;;
58 ;; | Boot Sector | ;;
59 ;; +------------------------+ A0000H - 3KB ;;
60 ;; | 3KB Boot Stack | ;;
61 ;; +------------------------+ A0000H ;;
62 ;; | Video RAM | ;;
63 ;; ;;
64 ;; ;;
65 ;; Boot Image Startup (register values): ;;
66 ;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;;
67 ;; ax = 0ffffh (both FCB in the PSP don't have a valid drive identifier), ;;
68 ;; bx = cx = 0, dl = BIOS boot drive number (e.g. 0, 80H) ;;
69 ;; cs:ip = program entry point ;;
70 ;; ss:sp = program stack (don't confuse with boot sector's stack) ;;
71 ;; COM program defaults: cs = ds = es = ss = 50h, sp = 0, ip = 100h ;;
72 ;; EXE program defaults: ds = es = EXE data - 10h (fake MS-DOS psp), ;;
73 ;; cs:ip and ss:sp depends on EXE header ;;
74 ;; Magic numbers: ;;
75 ;; si = 16381 (prime number 2**14-3) ;;
76 ;; di = 32749 (prime number 2**15-19) ;;
77 ;; bp = 65521 (prime number 2**16-15) ;;
78 ;; The magic numbers let the program know whether it has been loaded by ;;
79 ;; this boot sector or by MS-DOS, which may be handy for universal, bare- ;;
80 ;; metal and MS-DOS programs. ;;
81 ;; The command line contains no arguments. ;;
82 ;; ;;
83 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
85 %define bx(label) bx+label-boot
86 %define si(label) si+label-boot
87 NullEntryCheck equ 1 ; +3 bytes
88 ReadRetry equ 1 ; +9 bytes
89 LBAsupport equ 1 ; +16 bytes
90 Over2GB equ 1 ; +5 bytes
91 GeometryCheck equ 1 ; +18 bytes
93 [BITS 16]
94 [CPU 8086]
96 ImageLoadSeg equ 60h
97 StackSize equ 3072 ; Stack + cluster list
99 [SECTION .text]
100 [ORG 0]
102 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
103 ;; Boot sector starts here ;;
104 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
106 boot:
107 DriveNumber:
108 jmp short start ; MS-DOS/Windows checks for this jump
109 nop
110 bsOemName DB "BootProg" ; 0x03
112 ;;;;;;;;;;;;;;;;;;;;;
113 ;; BPB starts here ;;
114 ;;;;;;;;;;;;;;;;;;;;;
116 bpbBytesPerSector DW 0 ; 0x0B
117 bpbSectorsPerCluster DB 0 ; 0x0D
118 bpbReservedSectors DW 0 ; 0x0E
119 bpbNumberOfFATs DB 0 ; 0x10
120 bpbRootEntries DW 0 ; 0x11
121 bpbTotalSectors DW 0 ; 0x13
122 bpbMedia DB 0 ; 0x15
123 bpbSectorsPerFAT DW 0 ; 0x16
124 bpbSectorsPerTrack DW 0 ; 0x18
125 bpbHeadsPerCylinder DW 0 ; 0x1A
126 bpbHiddenSectors DD 0 ; 0x1C
127 bpbTotalSectorsBig DD 0 ; 0x20
129 ;;;;;;;;;;;;;;;;;;;
130 ;; BPB ends here ;;
131 ;;;;;;;;;;;;;;;;;;;
133 bsDriveNumber DB 0 ; 0x24
134 bsUnused DB 0 ; 0x25
135 bsExtBootSignature DB 0 ; 0x26
136 bsSerialNumber DD 0 ; 0x27
137 bsVolumeLabel DB "NO NAME " ; 0x2B
138 bsFileSystem DB "FAT12 " ; 0x36
140 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
141 ;; Boot sector code starts here ;;
142 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
144 start:
145 cld
147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
148 ;; How much RAM is there? ;;
149 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
151 int 12h ; get conventional memory size (in KBs)
152 mov cx, 106h
153 shl ax, cl ; and convert it to 16-byte paragraphs
155 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
156 ;; Reserve memory for the boot sector and its stack ;;
157 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
159 sub ax, (512+StackSize) /16 ; reserve bytes for the code and the stack
160 mov es, ax ; cs:0 = ds:0 = ss:0 -> top - 512 - StackSize
161 mov ss, ax
162 mov sp, 512+StackSize ; bytes 0-511 are reserved for the boot code
164 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
165 ;; Copy ourselves to top of memory ;;
166 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
168 mov si, 7C00h
169 xor di, di
170 mov ds, di
171 push es
172 mov [si(DriveNumber)], dx ; store BIOS boot drive number
173 rep movsw ; move 512 bytes (+ 12)
175 ;;;;;;;;;;;;;;;;;;;;;;
176 ;; Jump to the copy ;;
177 ;;;;;;;;;;;;;;;;;;;;;;
179 mov cl, byte main
180 push cx
181 retf
183 main:
184 %if ImageLoadSeg != main-boot
185 %if ImageLoadSeg >= 100h
186 mov cx, ImageLoadSeg
187 %else
188 mov cl, ImageLoadSeg
189 %endif
190 %endif
191 push cx
193 ;;;;;;;;;;;;;;;;;;;;;;;;;;
194 ;; Get drive parameters ;;
195 ;; Update heads count ;;
196 ;; for current BIOS ;;
197 ;;;;;;;;;;;;;;;;;;;;;;;;;;
199 %if GeometryCheck != 0
200 mov ah, 8
201 int 13h ; may destroy SI,BP, and DS registers
202 %endif
203 ; update AX,BL,CX,DX,DI, and ES registers
204 push cs
205 pop ds
206 xor bx, bx
208 %if GeometryCheck != 0
209 and cx, byte 3Fh
210 cmp [bx(bpbSectorsPerTrack)], cx
211 jne BadParams ; verify updated and validity
212 mov al, dh
213 inc ax
214 mov [bpbHeadsPerCylinder], ax
215 BadParams:
216 %endif
218 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
219 ;; Load FAT (FAT12: 6KB max, FAT16: 128KB max) ;;
220 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
222 pop es ; ImageLoadSeg
223 push es
225 mul bx ; dx:ax = 0 = LBA (LBA are relative to FAT)
226 mov cx, word [bx(bpbSectorsPerFAT)]
228 call ReadCXSectors ; read fat and clear ax & cx; bp = SectorsPerFAT
230 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
231 ;; load the root directory in ;;
232 ;; its entirety (16KB max) ;;
233 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
235 mov al, 32
237 mul word [bx(bpbRootEntries)]
238 div word [bx(bpbBytesPerSector)]
239 xchg ax, cx ; cx = root directory size in sectors, clear ax
241 mov al, [bpbNumberOfFATs]
242 mul bp ; [bx(bpbSectorsPerFAT)], set by ReadCXSectors
244 push es
245 call ReadCXSectors ; read root directory; clear ax, cx & di; bp = first data sector
246 pop es
248 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
249 ;; Look for the COM/EXE file to load and run ;;
250 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
252 ; es:di -> root entries array
254 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
255 ;; Looks for the file/dir ProgramName ;;
256 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
257 ;; Input: ES:DI -> root directory array ;;
258 ;; Output: SI = cluster number ;;
259 ;; AX = file sector count ;;
260 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
262 FindNameCycle:
263 push di
264 mov cl, 11
265 mov si, ProgramName ; ds:si -> program name
266 repe cmpsb
267 pop di
268 je FindNameFound
269 %if NullEntryCheck != 0
270 scasb
271 je FindNameFailed ; end of root directory (NULL entry found)
272 add di, byte 31
273 %else
274 add di, byte 32
275 %endif
276 dec word [bx(bpbRootEntries)]
277 jnz FindNameCycle ; next root entry
279 FindNameFailed:
280 call Error
281 db "File not found."
283 FindNameFound:
284 push si
285 mov si, [es:di+1Ah] ; si = cluster no.
286 les ax, [es:di+1Ch] ; file size
287 mov dx, es
288 div word [bx(bpbBytesPerSector)]
289 cmp bx, dx ; sector aligned ?
290 adc ax, bx ; file last sector
291 pop di ; di = ClusterList
293 pop es ; ImageLoadSeg
294 push ax
296 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
297 ;; build cluster list ;;
298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
299 ;; Input: ES:0 -> FAT ;;
300 ;; SI = first cluster ;;
301 ;; DI = cluster list :;
302 ;; CH = 0 ;;
303 ;; Output: SI = cluster list ;;
304 ;; CH = 0 ;;
305 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
307 FAT12 equ 1
308 FAT16 equ 1
309 push di ; up to 2 * 635K / BytesPerCluster bytes
310 %if FAT12 == 1
311 mov cl, 12
312 %endif
313 ClusterLoop:
314 mov [di], si
316 add si, si ; si = cluster * 2
317 %if FAT16 == 1
318 mov ax, es ; ax = FAT segment = ImageLoadSeg
319 jnc First64k
320 mov ah, (1000h+ImageLoadSeg)>>8 ; adjust segment for 2nd part of FAT16
321 First64k:
322 mov dx, 0FFF8h
323 %else
324 mov dx, 0FF8h
325 %endif
327 %if FAT12 == 1 && FAT16 == 1
328 cmp [bx(bpbSectorsPerFAT)], cx ; 1..12 = FAT12, 16..256 = FAT16
329 ja ReadClusterFat16
330 mov dh, 0Fh
331 %endif
332 %if FAT12 == 1
333 add si, [di]
334 shr si, 1 ; si = cluster * 3 / 2
335 %endif
336 %if FAT16 == 1
337 ReadClusterFat16:
338 push ds
339 mov ds, ax
340 lodsw ; ax = next cluster
341 pop ds
342 %else
343 lodsw ; ax = next cluster
344 %endif
345 %if FAT12 == 1
346 jnc ReadClusterEven
347 rol ax, cl
348 ReadClusterEven:
349 %endif
350 scasw ; di += 2
351 and ah, dh ; mask cluster value
352 cmp ax, dx
354 xchg ax, si
355 jc ClusterLoop
356 pop si
357 pop di ; file size in sectors
359 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
360 ;; Load the entire file ;;
361 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
362 ;; Input: ES:0 -> buffer ;;
363 ;; SI = cluster list ;;
364 ;; DI = file sectors ;;
365 ;; CH = 0 ;;
366 ;; BP = 1st data sec ;;
367 ;; Output: BP:0 -> buffer ;;
368 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
370 push es
372 ReadClusters:
373 lodsw
374 dec ax
375 dec ax
377 mov cl, [bx(bpbSectorsPerCluster)]
378 mul cx ; cx = sector count (ch = 0)
380 add ax, bp ; LBA for cluster data
381 adc dx, bx ; dx:ax = LBA
383 call ReadSector ; clear ax & cx, restore dx
385 jne ReadClusters
387 pop bp ; ImageLoadSeg
389 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
390 ;; Type detection, .COM or .EXE? ;;
391 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
393 mov ds, bp ; bp=ds=seg the file is loaded to
395 add bp, [bx+08h] ; bp = image base
396 mov di, [bx+18h] ; di = reloc table pointer
398 cmp word [bx], 5A4Dh ; "MZ" signature?
399 je RelocateEXE ; yes, it's an EXE program
401 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
402 ;; Setup and run a .COM program ;;
403 ;; Set CS=DS=ES=SS SP=0 IP=100h ;;
404 ;; AX=0ffffh BX=0 CX=0 DX=drive ;;
405 ;; and cmdline=void ;;
406 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
408 mov di, 100h ; ip
409 mov bp, ImageLoadSeg-10h ; "org 100h" stuff :)
410 mov ss, bp
411 xor sp, sp
412 push bp ; cs, ds and es
413 jmp short Run
415 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
416 ;; Relocate, setup and run a .EXE program ;;
417 ;; Set CS:IP, SS:SP, DS, ES and AX according ;;
418 ;; to wiki.osdev.org/MZ#Initial_Program_State ;;
419 ;; AX=0ffffh BX=0 CX=0 DX=drive cmdline=void ;;
420 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
422 ReloCycle:
423 add [di+2], bp ; item seg (abs)
424 les si, [di] ; si = item ofs, es = item seg
425 add [es:si], bp ; fixup
426 scasw ; di += 2
427 scasw ; point to next entry
429 RelocateEXE:
430 dec word [bx+06h] ; reloc items, 32768 max (128KB table)
431 jns ReloCycle
432 ; PSP don't have a valid drive identifier
433 les si, [bx+0Eh]
434 add si, bp
435 mov ss, si ; ss for EXE
436 mov sp, es ; sp for EXE
438 lea si, [bp-10h] ; ds and es both point to the segment
439 push si ; containing the PSP structure
441 add bp, [bx+16h] ; cs for EXE
442 mov di, [bx+14h] ; ip for EXE
443 Run:
444 pop ds
445 push bp
446 push di
447 push ds
448 pop es
449 mov [80h], ax ; clear cmdline
450 dec ax ; both FCB in the PSP don't have a valid drive identifier
452 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
453 ;; Set the magic numbers so the program knows that it ;;
454 ;; has been loaded by this bootsector and not by MS-DOS ;;
455 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
456 mov si, 16381 ; prime number 2**14-3
457 mov di, 32749 ; prime number 2**15-19
458 mov bp, 65521 ; prime number 2**16-15
460 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
461 ;; All done, transfer control to the program now ;;
462 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
463 retf
465 ReadCXSectors:
466 mov bp, cx
467 add bp, ax ; adjust LBA for cluster data
469 mov di, cx ; no file size limit
471 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
472 ;; Reads sectors using BIOS Int 13h ;;
473 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
474 ;; Input: DX:AX = LBA relative to FAT ;;
475 ;; BX = 0 ;;
476 ;; CX = sector count ;;
477 ;; DI = file sectors ;;
478 ;; ES:BX -> buffer address ;;
479 ;; Output: ES:BX -> next address ;;
480 ;; BX = 0 ;;
481 ;; CX or DI = 0 ;;
482 ;; DL = drive number ;;
483 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
485 ReadSector:
486 add ax, [bx(bpbHiddenSectors)]
487 adc dx, [bx(bpbHiddenSectors)+2]
488 add ax, [bx(bpbReservedSectors)]
490 push si
491 ReadSectorNext:
492 adc dx, bx
493 push di
494 push cx
496 %if LBAsupport != 0
497 push bx
498 push bx
499 %endif
500 push dx ; 32-bit LBA: up to 2TB
501 push ax
502 push es
503 %if ReadRetry != 0 || LBAsupport != 0
504 mov di, 16 ; packet size byte = 16, reserved byte = 0
505 %endif
506 %if LBAsupport != 0
507 push bx
508 inc bx ; sector count word = 1
509 push bx
510 dec bx
511 push di
512 %endif
514 %if Over2GB != 0
515 xchg ax, cx ; save low LBA
516 xchg ax, dx ; get high LBA
517 cwd ; clear dx (LBA offset <1TB)
518 idiv word [bx(bpbSectorsPerTrack)] ; up to 8GB disks
520 xchg ax, cx ; restore low LBA, save high LBA / SPT
521 %else
522 xor cx, cx ; up to 2GB disks otherwise divide error interrupt !
523 %endif
524 idiv word [bx(bpbSectorsPerTrack)]
525 ; ax = LBA / SPT
526 ; dx = LBA % SPT = sector - 1
527 inc dx
529 xchg cx, dx ; restore high LBA / SPT, save sector no.
530 idiv word [bx(bpbHeadsPerCylinder)]
531 ; ax = (LBA / SPT) / HPC = cylinder
532 ; dx = (LBA / SPT) % HPC = head
533 mov ch, al
534 ; ch = LSB 0...7 of cylinder no.
535 mov al, 64
536 mul ah
537 or cl, al
538 ; cl = MSB 8...9 of cylinder no. + sector no.
539 mov dh, dl
540 ; dh = head no.
542 ReadSectorRetry:
543 mov dl, [bx(DriveNumber)]
544 ; dl = drive no.
545 mov si, sp
546 %if LBAsupport != 0
547 mov ah, 42h ; ah = 42h = extended read function no.
548 int 13h ; extended read sectors (DL, DS:SI)
549 jnc ReadSectorNextSegment
550 %endif
552 mov ax, 201h ; al = sector count = 1
553 ; ah = 2 = read function no.
554 int 13h ; read sectors (AL, CX, DX, ES:BX)
556 jnc ReadSectorNextSegment
557 %if ReadRetry != 0
558 cbw ; ah = 0 = reset function
559 int 13h ; reset drive (DL)
561 dec di
562 jnz ReadSectorRetry ; extra attempt
563 %endif
565 call Error
566 db "Read error."
568 ReadSectorNextSegment:
570 %if LBAsupport != 0
571 pop ax ; al = 16
572 mul byte [bx(bpbBytesPerSector)+1] ; = (bpbBytesPerSector/256)*16
573 pop cx ; sector count = 1
574 pop bx
575 add [si+6], ax ; adjust segment for next sector
576 %else
577 mov al, 16
578 mul byte [bx(bpbBytesPerSector)+1] ; = (bpbBytesPerSector/256)*16
579 add [si], ax ; adjust segment for next sector
580 %endif
581 pop es ; es:0 updated
582 pop ax
583 pop dx
584 %if LBAsupport != 0
585 pop di
586 pop di
587 add ax, cx ; adjust LBA for next sector
588 %else
589 add ax, 1 ; adjust LBA for next sector
590 %endif
592 pop cx ; cluster sectors to read
593 pop di ; file sectors to read
594 dec di ; keep C
595 loopne ReadSectorNext ; until cluster sector count or file sector count is reached
596 pop si
597 mov ax, bx ; clear ax
598 mov dx, [bx(DriveNumber)] ; pass the BIOS boot drive to Run or Error
600 ret
602 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
603 ;; Fill free space with zeroes ;;
604 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
606 times (512-13-20-($-$$)) db 0
608 ;;;;;;;;;;;;;;;;;;;;;;;;;;
609 ;; Error Messaging Code ;;
610 ;;;;;;;;;;;;;;;;;;;;;;;;;;
612 Error:
613 pop si
615 PutStr:
616 mov ah, 0Eh
617 mov bl, 7
618 lodsb
619 int 10h
620 cmp al, "."
621 jne PutStr
623 cbw
624 int 16h ; wait for a key...
625 int 19h ; bootstrap
627 Stop:
628 hlt
629 jmp short Stop
631 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
632 ;; Name of the file to load and run ;;
633 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
635 ProgramName db "STARTUP BIN" ; name and extension each must be
636 times (510-($-$$)) db ' ' ; padded with spaces (11 bytes total)
638 ;;;;;;;;;;;;;;;;;;;;;;;;;;
639 ;; End of the sector ID ;;
640 ;;;;;;;;;;;;;;;;;;;;;;;;;;
642 ClusterList dw 0AA55h ; BIOS checks for this ID