首页 > 其他 > 详细

BootLoader (启动加载)

时间:2014-04-27 07:56:32      阅读:579      评论:0      收藏:0      [点我收藏+]

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

 

进入正题:

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

                  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


 

 

 

 

 

                                                

                            

BootLoader (启动加载),布布扣,bubuko.com

BootLoader (启动加载)

原文:http://blog.csdn.net/qqzwp/article/details/24521123

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!