[ORG 0x7c00] jmp short start nop ;1.44 MB 3.5" floppy disk description table OEMLabel db "EttinOS " BytesPerSector dw 0x200 SectorsPerCluster db 0x1 BootRecordSectors dw 0x1 FATs db 0x2 RootEntries dw 0xe0 LogicalSectors dw 0xb40 MediaDescriptor db 0xf0 SectorsPerFAT dw 0x9 SectorsPerTrack dw 0x12 Sides dw 0x2 HiddenSectors dd 0x0 LargeSectors dd 0x0 DriveNumber dw 0x0 DriveSignature db 0x29 VolumeID dd 0x0 VolumeLabel db "EttinOS " FileSystem db "FAT12 " start: ;Set up the data segment mov ax, 0x0 mov ds, ax ;Set up the stack cli mov ax, 0x0 mov ss, ax mov sp, 0x7c00 sti ;Store the boot device number mov [bootdev], dl ;Load the root FAT ;Set the source mov ax, 0x13 call calcsource ;Set the destination mov si, 0x7e00 mov bx, ds mov es, bx mov bx, si ;Set the size mov al, 0xe ;Load mov ah, 0x2 int 0x13 ;Search the root FAT for the system ;Set DI to the root FAT mov ax, ds mov es, ax mov di, 0x7e00 ;Initialise the search loop mov cx, word [RootEntries] mov ax, 0x0 search: ;Store CX in the stack push cx ;Check for the binary mov si, sysfile mov cx, 0xb rep cmpsb je loadsysfat ;Set DI to the next entry add ax, 0x20 mov di, 0x7e00 add di, ax ;Load CX from the stack pop cx loop search ;Load the system FAT loadsysfat: ;??? mov ax, word [es:di+0xf] mov word [cluster], ax ;Set the source mov ax, 0x1 call calcsource ;Set the destination mov di, 0x7e00 mov bx, di ;Set the size mov al, 0x9 ;Load mov ah, 0x2 int 0x13 ;Load the system loadsys: ;Set the source mov ax, word [cluster] add ax, 0x1f call calcsource ;Set the destination mov ax, 0x0 mov es, ax mov bx, word [pointer] ;Set the size mov al, 0x1 ;Load a cluster mov ah, 0x2 int 0x13 ;Calculate the next cluster mov ax, [cluster] mov dx, 0x0 mov bx, 0x3 mul bx mov bx, 2 div bx mov si, 0x7e00 add si, ax mov ax, word [ds:si] or dx, dx jz even odd: shr ax, 4 jmp contcluster even: and ax, 0xfff contcluster: mov word [cluster], ax cmp ax, 0xff8 jge boot add word [pointer], 0x200 jmp loadsys boot: jmp 0x0:0x9e00 sysfile: db "SYSTEM BIN" bootdev: db 0 cluster: dw 0x0 pointer: dw 0x9e00 calcsource: push ax push bx mov bx, ax mov dx, 0x0 div word [SectorsPerTrack] add dl, 0x1 mov cl, dl mov ax, bx mov dx, 0x0 div word [SectorsPerTrack] mov dx, 0x0 div word [Sides] mov dh, dl mov ch, al pop bx pop ax mov dl, byte [bootdev] ret ;Padding times 0x1fe-($-$$) db 0x0 ;Boot signature dw 0xaa55