2019-07-05 19:44:28 +02:00
|
|
|
use16
|
|
|
|
align 1
|
2007-03-13 21:56:55 +01:00
|
|
|
|
|
|
|
include "..\include\mem.h"
|
|
|
|
include "..\include\fat.h"
|
|
|
|
include "..\include\divers.h"
|
|
|
|
|
2004-06-12 23:34:04 +02:00
|
|
|
org 7C00h
|
|
|
|
|
|
|
|
jmp boot
|
|
|
|
|
2019-07-05 19:44:28 +02:00
|
|
|
bootsec bootinfo "COS2000A","COS2000 ","FAT12 "
|
2007-03-13 21:56:55 +01:00
|
|
|
|
|
|
|
errorloading db " [Erreur]",0dh,0ah,0
|
|
|
|
okloading db "Recherche noyau ",0Dh,0ah," -"
|
|
|
|
sys db "SYSTEME SYS",0
|
|
|
|
syst db " [ Ok ]",0dh,0ah,"Chargement ",0
|
|
|
|
dot db ".",0
|
|
|
|
|
2004-06-12 23:34:04 +02:00
|
|
|
errorboot:
|
2019-07-05 19:44:28 +02:00
|
|
|
mov si,errorloading
|
2007-03-13 21:56:55 +01:00
|
|
|
call showstr
|
|
|
|
mov ah,0
|
|
|
|
int 16h
|
|
|
|
int 19h
|
|
|
|
|
2004-06-12 23:34:04 +02:00
|
|
|
boot:
|
2007-03-13 21:56:55 +01:00
|
|
|
mov [bootsec.bootdrive],dl
|
2004-06-12 23:34:04 +02:00
|
|
|
cli
|
2007-03-13 21:56:55 +01:00
|
|
|
mov ax,09000h
|
|
|
|
mov ss,ax
|
|
|
|
mov sp,0FFFFh
|
|
|
|
sti
|
2004-06-12 23:34:04 +02:00
|
|
|
boot2:
|
2007-03-13 21:56:55 +01:00
|
|
|
push cs
|
|
|
|
push cs
|
|
|
|
pop es
|
|
|
|
pop ds
|
|
|
|
xor ax,ax
|
|
|
|
mov dl,[bootsec.bootdrive]
|
|
|
|
int 13h
|
|
|
|
jc errorboot
|
2019-07-05 19:44:28 +02:00
|
|
|
mov si,okloading
|
2007-03-13 21:56:55 +01:00
|
|
|
call showstr
|
|
|
|
mov cx,[bootsec.reservedsectors]
|
|
|
|
add cx,[bootsec.hiddensectorsh]
|
|
|
|
adc cx,[bootsec.hiddensectorsl]
|
|
|
|
push cx
|
|
|
|
mov bx,[bootsec.sectorsperfat]
|
2019-07-05 19:44:28 +02:00
|
|
|
mov di,bufferfat
|
2004-06-12 23:34:04 +02:00
|
|
|
readfat:
|
2007-03-13 21:56:55 +01:00
|
|
|
call readsector
|
|
|
|
jc errorboot
|
|
|
|
inc cx
|
|
|
|
add di,[bootsec.sectorsize]
|
|
|
|
dec bx
|
|
|
|
jnz readfat
|
|
|
|
pop cx
|
|
|
|
xor ax,ax
|
|
|
|
mov al,[bootsec.fatsperdrive]
|
|
|
|
mov bx,[bootsec.sectorsperfat]
|
|
|
|
mul bx
|
|
|
|
add cx,ax
|
|
|
|
mov ax,32
|
|
|
|
mul [bootsec.directorysize]
|
|
|
|
div [bootsec.sectorsize]
|
|
|
|
add ax,cx
|
|
|
|
sub ax,2
|
2019-07-05 19:44:28 +02:00
|
|
|
mov word [bootsec.reservedfornt],ax
|
2007-03-13 21:56:55 +01:00
|
|
|
xor dx,dx
|
|
|
|
checkroot:
|
2019-07-05 19:44:28 +02:00
|
|
|
mov di,buffer
|
2007-03-13 21:56:55 +01:00
|
|
|
call readsector
|
|
|
|
jc errorboot
|
|
|
|
xor bx,bx
|
2004-06-12 23:34:04 +02:00
|
|
|
findnext:
|
2019-07-05 19:44:28 +02:00
|
|
|
cmp byte [di],0
|
2007-03-13 21:56:55 +01:00
|
|
|
je errorboot
|
2019-07-05 19:44:28 +02:00
|
|
|
cmp byte [di],0E5h
|
2007-03-13 21:56:55 +01:00
|
|
|
je no
|
2019-07-05 19:44:28 +02:00
|
|
|
cmp byte [di],041h
|
2007-03-13 21:56:55 +01:00
|
|
|
je no
|
2019-07-05 19:44:28 +02:00
|
|
|
mov si,dot
|
2007-03-13 21:56:55 +01:00
|
|
|
call showstr
|
|
|
|
push di cx
|
2019-07-05 19:44:28 +02:00
|
|
|
mov si,sys
|
2007-03-13 21:56:55 +01:00
|
|
|
mov cx,11
|
|
|
|
rep cmpsb
|
|
|
|
pop cx di
|
|
|
|
je oksystem
|
2004-06-12 23:34:04 +02:00
|
|
|
no:
|
2007-03-13 21:56:55 +01:00
|
|
|
add di,32
|
|
|
|
add bx,32
|
|
|
|
inc dx
|
|
|
|
cmp dx,[bootsec.directorysize]
|
|
|
|
ja errorboot
|
|
|
|
cmp bx,[bootsec.sectorsize]
|
|
|
|
jb findnext
|
|
|
|
inc cx
|
|
|
|
jmp checkroot
|
2004-06-12 23:34:04 +02:00
|
|
|
oksystem:
|
2019-07-05 19:44:28 +02:00
|
|
|
mov si,syst
|
2007-03-13 21:56:55 +01:00
|
|
|
call showstr
|
|
|
|
mov cx,[di+26]
|
2007-03-14 12:03:25 +01:00
|
|
|
mov ax,8000h
|
2007-03-13 21:56:55 +01:00
|
|
|
mov es,ax
|
|
|
|
push es
|
|
|
|
mov di,0000h
|
|
|
|
push 0010h
|
2019-07-05 19:44:28 +02:00
|
|
|
mov si,dot
|
2007-03-13 21:56:55 +01:00
|
|
|
xor ax,ax
|
2004-06-12 23:34:04 +02:00
|
|
|
fatagain:
|
2007-03-13 21:56:55 +01:00
|
|
|
cmp cx,0FF0h
|
|
|
|
jae finishload
|
|
|
|
push cx
|
2019-07-05 19:44:28 +02:00
|
|
|
add cx,word [bootsec.reservedfornt]
|
2007-03-13 21:56:55 +01:00
|
|
|
call readsector
|
|
|
|
pop cx
|
|
|
|
jc errorboot
|
2004-06-12 23:34:04 +02:00
|
|
|
inc ax
|
2007-03-13 21:56:55 +01:00
|
|
|
call showstr
|
|
|
|
add di,[bootsec.sectorsize]
|
|
|
|
call getfat
|
|
|
|
jnc fatagain
|
2004-06-12 23:34:04 +02:00
|
|
|
finishload:
|
2007-03-13 21:56:55 +01:00
|
|
|
retf
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
|
|
;=============READSECTOR (Fonction 01H)===============
|
|
|
|
;Lit le secteur CX et le met en es:di
|
|
|
|
;-> AH=1
|
|
|
|
;<- Flag Carry si erreur
|
|
|
|
;=====================================================
|
2007-03-13 21:56:55 +01:00
|
|
|
readsector:
|
2004-06-12 23:34:04 +02:00
|
|
|
push ax bx cx dx si
|
|
|
|
mov ax,cx
|
2007-03-13 21:56:55 +01:00
|
|
|
xor dx,dx
|
|
|
|
div [bootsec.sectorspertrack]
|
|
|
|
inc dl
|
|
|
|
mov bl,dl
|
|
|
|
xor dx,dx
|
|
|
|
div [bootsec.headsperdrive]
|
|
|
|
xchg dl,dh
|
|
|
|
mov cx,ax
|
|
|
|
xchg cl,ch
|
|
|
|
shl cl,6
|
|
|
|
or cl, bl
|
2004-06-12 23:34:04 +02:00
|
|
|
mov bx,di
|
2007-03-13 21:56:55 +01:00
|
|
|
mov si, 4
|
|
|
|
mov al, 1
|
|
|
|
tryagain:
|
|
|
|
mov ah, 2
|
|
|
|
mov dl,[bootsec.bootdrive]
|
2004-06-12 23:34:04 +02:00
|
|
|
int 13h
|
2007-03-13 21:56:55 +01:00
|
|
|
jnc done
|
|
|
|
dec si
|
|
|
|
jnz tryagain
|
|
|
|
done:
|
2004-06-12 23:34:04 +02:00
|
|
|
pop si dx cx bx ax
|
2007-03-13 21:56:55 +01:00
|
|
|
ret
|
|
|
|
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
|
|
getfat:
|
2007-03-13 21:56:55 +01:00
|
|
|
push ax bx dx di
|
2019-07-05 19:44:28 +02:00
|
|
|
mov di,bufferfat
|
2004-06-12 23:34:04 +02:00
|
|
|
mov ax,cx
|
|
|
|
mov bx,ax
|
2007-03-13 21:56:55 +01:00
|
|
|
and bx,0000000000000001b
|
|
|
|
shr ax,1
|
|
|
|
mov cx,3
|
|
|
|
mul cx
|
|
|
|
add di,ax
|
|
|
|
cmp bx,0h
|
|
|
|
jnz evenfat
|
2004-06-12 23:34:04 +02:00
|
|
|
oddfat:
|
|
|
|
mov dx,[di]
|
2007-03-13 21:56:55 +01:00
|
|
|
and dx,0FFFh
|
|
|
|
mov cx,dx
|
|
|
|
jmp endfat
|
2004-06-12 23:34:04 +02:00
|
|
|
evenfat:
|
2007-03-13 21:56:55 +01:00
|
|
|
mov dx,[di+1]
|
|
|
|
and dx,0FFF0h
|
|
|
|
shr dx,4
|
|
|
|
mov cx,dx
|
2004-06-12 23:34:04 +02:00
|
|
|
endfat:
|
2007-03-13 21:56:55 +01:00
|
|
|
pop di dx bx ax
|
2004-06-12 23:34:04 +02:00
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
|
|
showstr:
|
2007-03-13 21:56:55 +01:00
|
|
|
push ax bx si
|
2004-06-12 23:34:04 +02:00
|
|
|
again:
|
|
|
|
lodsb
|
2007-03-13 21:56:55 +01:00
|
|
|
or al,al
|
|
|
|
jz fin
|
|
|
|
mov ah,0Eh
|
|
|
|
mov bx,07h
|
|
|
|
int 10h
|
|
|
|
jmp again
|
|
|
|
fin:
|
|
|
|
pop si bx ax
|
2004-06-12 23:34:04 +02:00
|
|
|
ret
|
2004-11-19 18:14:08 +01:00
|
|
|
|
2019-07-05 19:44:28 +02:00
|
|
|
rb 7C00h+512-2-$
|
2004-11-19 18:14:08 +01:00
|
|
|
db 055h,0AAh
|
2004-06-12 23:34:04 +02:00
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
endof:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
2019-07-05 19:44:28 +02:00
|
|
|
buffer:
|
|
|
|
rb 7C00h+512+2048-$
|
|
|
|
bufferfat:
|
|
|
|
rb 7C00h+512+4096-$
|
2004-06-12 23:34:04 +02:00
|
|
|
|