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