BootLoader (启动加载)

由于浪儿要参加一个比赛,所以博客有时候会顾不上来。

 

进入正题:

                 学习数据结构的三个阶段:

                  I: 理解某种数据结构,能够熟练实现之!

                  II: 能够用该种数据结构开发出有一定价值的应用软件!

                  III: 能够优化这种数据结构,为了不同的应用而将其创新,改进,以适应自己的需要!

 

真正的正题:

                                               BootLoader(初识)

 

;-------------------------------------------------------------------
;boot1.asm
;
;---------------------------------------------------------------------





bits	16		; we are still in 16 bit real mode
org	0x7c00		; we are loaded by BIOS at 0x7c00
start:	jmp	loader	; jump over OEM block

;------------------------------------------------------
; OEM Parameter block
;-------------------------------------------------------

TIMES 0Bh-$+start DB	0

bpbOEM	db	"My OS"			; This number must be exactally 8 bytes, it 
					; is just the name of your OS, Everything else
					; remains the same.

bpbBytesPerSector:	DW	512
bpbSectorsPerCluster:	DB	1
bpbReservedSectors:	DW	1
bpbNumberOfFATs:	DB	2
bpbRootEntries:		DW	224
bpbTotalSectors:	DW	2880
bpbMedia:		DB	0XF0
bpbSectorsPerFAT:	DW	9
bpbSectorsPerTrack:	DW	18
bpbHeadsPerCylinder:	DW	2
bpbHiddenSectors:	DD	0
bpbTotalSectorsBig:	DD	0
bsDirveNumber:		DB	0
bsUnused:		DB	0
bsExtBootSignature:	DB	0X29
bsSerialNumber:		DD	0xa0a1a2a3
bsVolumeLabel:		DB	"MOS FLOPPY"
bsFileSystem:		DB	"FAT12"



msg	db	"Welcome to my Operating System!", 0

;------------------------------------------------------
; Print a string
; DS->SI: 0 terminated string
;------------------------------------------------------

Print:
	lodsb
	or	al, al	; al = current character
	jz	PrintDone ; null terminator found 
	mov	ah, 0eh	; get next character
	int	10h	; print char on screen
	jmp	Print	

PrintDone:
	ret		; return intrerupt


;----------------------------------------------------------------------
; Bootloader Entry Point
;---------------------------------------------------------------------------

loader:
	xor ax, ax	; setup segments to insure they are 0, remember that
	mov ds, ax	; we have ORG 0x7C00, this means all addresses are based
	mov es, ax	; from 0x7c00:0, Because the data segments are within the same
			; code segment
	mov si, msg
	call	Print
	xor ax, ax	; clear ax
	int 0x12	; get the amout of KB from the BIOS
	
	cli		; clear all interrupts
	hlt		; halt the system

	times 510 - ($-$$) db 0; we have to be 512 bytes, clear the rest of the bytes with 0
	dw	0xAA55	; boot signiture


 

 

 

 

 

                                                

                            

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值