Import backup from 2003-08-04

This commit is contained in:
Josh Holtrop 2003-08-04 22:00:00 -04:00
parent 7a4586bb06
commit e6805ee94c

View File

@ -134,76 +134,69 @@ error:
jmp $ ;halt! no kernel file found! jmp $ ;halt! no kernel file found!
found_file: ;ds:si points to root dir entry of kernel file found_file: ;ds:si points to root dir entry of kernel file
mov di, 160 ;;;;;;;
mov ax, KERNEL_SEG mov ax, KERNEL_SEG
mov es, ax mov es, ax
mov ax, [ds:si+26] ;first logical cluster
mov ax, [ds:si+26]
mov bx, FAT_SEG mov bx, FAT_SEG
mov ds, bx mov ds, bx ;ds points to beginning of FAT
xor bx, bx xor bx, bx
loop_readkernel:
cmp ax, 0xFF7 readkernel_loop:
jg donereadkernel cmp ax, 0xff7
push ax ;<> save cluster# jg readkernel_done
push bx ;<> save index ;inc word [k_count]
push ax
push bx
call getCHSfromCluster call getCHSfromCluster
pop bx
push bx
mov ax, 0x0201 mov ax, 0x0201
mov dl, [brDrive] mov dl, [brDrive]
int 0x13 int 0x13
pop bx pop bx
add bx, 512 add bx, 512
pop ax ;<> restore cluster# cmp bx, 0
cmp bx, 0 ;if bx=0 then it wrapped, 64k loaded, increment es by 64k jne readkernel_goon
jne loop_readkernel_goon
mov bx, es mov bx, es
add bx, 0x1000 add bx, 0x0100
mov es, bx mov es, bx
xor bx, bx xor bx, bx
loop_readkernel_goon: readkernel_goon:
mov cx, ax ;save backup of cluster# pop ax ;current logical cluster #
mov cx, ax ;cx=logical cluster
mov dx, 3 mov dx, 3
mul dx ;ax=logical cluster*3 mul dx
shr ax, 1 ;ax=logical cluster*3/2 shr ax, 1 ;ax=logical cluster * 3 / 2
mov si, ax ;ds:si points to first byte of word containing FAT entry mov si, ax
test cl, 1 ;is cluster# odd? test cl, 1 ;is bit0 set?
jnz odd_cluster jnz odd_cluster
even_cluster: even_cluster:
mov cl, [ds:si+1] lodsw
and cl, 0x0f and ax, 0x0fff
shl cx, 8
mov cl, [ds:si]
jmp got_cluster jmp got_cluster
odd_cluster: odd_cluster:
xor cx, cx lodsw
mov cl, [ds:si+1] shr ax, 4
shl cx, 4
xor dx, dx
mov dl, [ds:si]
shr dl, 4
add cx, dx
got_cluster: got_cluster:
push es ;;;;;;; jmp readkernel_loop
mov ax, 0xb800
mov es, ax
mov al, ch
call puthex
mov al, cl
call puthex
inc di
inc di ;;;;;;;
mov ax, cx readkernel_done: ;now copy kernel to final location in KERNEL_ADD!
jmp loop_readkernel
donereadkernel: ;done reading kernel! ; mov ax, KERNEL_SEG
mov ax, 0xb800 ; mov ds, ax
mov es, ax ; xor esi, esi
xor di, di ; xor ax, ax
mov al, bh ; mov es, ax
call puthex ; mov edi, KERNEL_ADD
mov al, bl ; xor ecx, ecx
call puthex ; mov cx, [k_count] ;cx=# of 512byte sectors loaded
; shl ecx, 9 ;ecx=ecx*512
;movekernel_loop:
; o32 lodsb ;mov al, [ds:esi]
; o32 stosb ;mov [es:edi], al
; o32 loop movekernel_loop
jmp $ jmp $
@ -224,35 +217,35 @@ getCHSfromCluster:
ret ret
;------------------------------------------------------ ;------------------------------------------------------
puthex: ;puthex:
;es:di points to video memory ; ;es:di points to video memory
;al holds hex value ; ;al holds hex value
;
push ax ; push ax
mov ah, al ; mov ah, al
shr ax, 4 ; shr ax, 4
and al, 0x0F ; and al, 0x0F
add al, '0' ; add al, '0'
cmp al, '9' ; cmp al, '9'
jle puthex_goon1 ; jle puthex_goon1
add al, 'A'-'9'-1 ; add al, 'A'-'9'-1
puthex_goon1: ;puthex_goon1:
stosb ; stosb
mov al, 7 ; mov al, 7
stosb ; stosb
pop ax ; pop ax
push ax ; push ax
and al, 0x0F ; and al, 0x0F
add al, '0' ; add al, '0'
cmp al, '9' ; cmp al, '9'
jle puthex_goon2 ; jle puthex_goon2
add al, 'A'-'9'-1 ; add al, 'A'-'9'-1
puthex_goon2: ;puthex_goon2:
stosb ; stosb
mov al, 7 ; mov al, 7
stosb ; stosb
pop ax ; pop ax
ret ; ret
;------------------------------------------------------- ;-------------------------------------------------------
gdtr: gdtr:
@ -274,6 +267,7 @@ gdt:
gdt_end: gdt_end:
kernel: db "KERNEL BIN" kernel: db "KERNEL BIN"
k_count: dw 0
times 510-($-$$) db 0 times 510-($-$$) db 0