操作系统-001- 环境配置

参考书:一个64位操作系统的设计与实现

第一个boot程序代码如下,基本上没有不理解的地方

org	 0x7c00	                       ;必须指定位置,不然编译器会将其放到位置0

BaseOfStack	equ	0x7c00

Label_Start:

	mov	ax,	cs
	mov	ds,	ax
	mov	es,	ax
	mov	ss,	ax
	mov	sp,	BaseOfStack

;=======	clear screen

	mov	ax,	0600h              ;中断10h,ax不同的值有不同功能
	mov	bx,	0700h
	mov	cx,	0
	mov	dx,	0184fh
	int	10h

;=======	set focus

	mov	ax,	0200h
	mov	bx,	0000h
	mov	dx,	0000h
	int	10h

;=======	display on screen : Start Booting......

	mov	ax,	1301h
	mov	bx,	000fh
	mov	dx,	0000h
	mov	cx,	StartBootMessagend-StartBootMessage
	push	ax
	mov	ax,	ds
	mov	es,	ax
	pop	ax
	mov	bp,	StartBootMessage
	int	10h

;=======	reset floppy

	xor	ah,	ah
	xor	dl,	dl
	int	13h

	jmp $	

StartBootMessage:	db	"Start Boot..."
StartBootMessagend:

;=======	fill zero until whole sector

	times	510 - ($ - $$)	db	0
	dw	0xaa55

在安装boches的时候出现问题,Ubuntu是16.04, bochs官网的下载不了,最后从github上下载 https://github.com/lubomyr/bochs,版本是bochs2.6.11

安装步骤参考https://blog.csdn.net/dc_726/article/details/7032440

配置文件bochsre如下

###############################################################
# Configuration file for Bochs
###############################################################

# how much memory the emulated machine will have
megs: 32
 
# filename of ROM images
romimage: file=/usr/local/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/local/share/bochs/VGABIOS-lgpl-latest
 
# what disk images will be used
floppya: 1_44=a.img, status=inserted
 
# choose the boot disk.
boot: floppy
 
# where do we send log messages?
# log: bochsout.txt
 
# disable the mouse
mouse: enabled=1
 
# enable key mapping, using US layout as default.
keyboard:keymap=/usr/local/share/bochs/keymaps/x11-pc-us.map

将bin烧写到fd

dd if=boot.bin of=a.img bs=512 count=1 conv=notrunc

正常进入debug模式,运行结果如下:

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值