📄 boot.asm
字号:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Project: LeeOS
;; Author: Robert Lee <robert.lee@leeos.cjb.net>
;; Date: Thursday, January 04, 2001
;; Description: LeeOS bootloader
;; Binary Location: [Partition bootsector]
;;
;; Notes:
;; This file loads and executes the LeeOS init routine. See init.asm.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.model tiny
.code
.386
jmp start ; Jump over BIOS parameter block
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; BIOS Parameter Block
;;
;; Disk information for FAT-based filesystems
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
db 'LeeOS0.0' ; LeeOS Version 0.0
dw 512 ; 512 bytes per sector
db 1 ; 1 sectors per cluster
dw 1 ; 1 reserved sector
db 2 ; 2 file allocation tables
dw 224 ; 224 root entries
dw 2880 ; 2880 small sectors
db 240 ; Media type 240 (1.44MB Floppy)
dw 9 ; 9 sectors in FAT
sectors dw 18 ; 18 sectors per track
heads dw 2 ; 2 heads
dd 0 ; No hidden sectors
dd 0 ; No large sectors
db 0 ; Drive number 0 (A:)
db 0 ; NT "dirty" flags clear
db 29h ; Extended BIOS paramter block
dd 0 ; Blank serial number
db 'NO NAME ' ; No disk label
db 'FAT12 ' ; Fat12 Filesystem
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Load & Execute Initialization Sequence
;;
;; Load and run the initialization sequence (init.asm). This file will be
;; located at '/system/init.sys' on the disk when FAT12 is implimented.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
start:
cli ; Disable interrupts
mov ax, 9000h ; Put stack at 0x90000
mov ss, ax
mov sp, 0
sti ; Enable interrupts
loadsect:
push ds ; Reset disk controller
mov dl, 0
mov ah, 0
int 13h
pop ds
jc fail ; Unable to reset disks
push es ; Load 5 sectors
mov ax,3000h ; ES:BX = 3000
mov es,ax
mov bx, 0
mov ah, 2 ; Read disk sectors
mov al, 5 ; read 5 sectors
mov cx, 2 ; Cylinder=0, sector=2
mov dx, 0 ; head=0, drive=0
int 13h ; ES:BX = data from disk
pop es
jc loadsect
mov ax,3000h ; set segment registers and jump
mov es,ax
mov ds,ax
push ax
mov ax,0
push ax
retf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; LHA -> CHS Convertion Procedure
;;
;; Get CYL, HEAD and SECT from LHA
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;LHA dw ?
;CYL db ?
;HEAD db ?
;SECT db ?
;GetCHS proc
; mov EAX, LHA ; EAX = LHA, AX = LHA LO
; ; AX = LBA LO
; mov DX,0 ; DX = LBA HI (zero)
; mov BX,AX ; BX = LHA LO
; mov AX,DX ; AX = LHA HI
; xor DX,DX ; DX = 0
; div sectors ; divide LBA HI by Sectors
; mov CX,AX ; save HI part of result in CX
; mov AX,BX ; restore AX to LBA LO
; div sectors ; divide REMINDER:LBA LO by Sectors
; inc DX ; make sector one-based
; xchg CX,DX ; swap sector and HI result
; div heads ; divide by Heads
; mov CYL,AX ; CYL = AX = Cylinder Number
; mov HEAD,DX ; HEAD = DX = Head Number
; mov SECT,CX ; SECT = CX = Sector Number
; ret
;GetCHS endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Fail
;;
;; Unable to boot? Call 1-800-Who-Cares
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
fail:
jmp $
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Boot Signature
;;
;; The BIOS is a small-minded beast.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 510
dw 55AAh
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -