bochs基础使用

这篇博客介绍了如何使用Bochs模拟器安装、配置,并从ASM源码构建一个简单的‘Hello, OS world!’操作系统。内容包括编写ASM代码、编译成二进制文件、创建磁盘映像以及启动Bochs进行运行。
摘要由CSDN通过智能技术生成

bochs

1、安装

sudo apt-get install bochs

sudo apt-get install bochs-x

2、编写文件

vim boot.asm
org 07c00h ; 告诉编译器程序加载到 7c00处   
    mov ax, cs   
    mov ds, ax   
    mov es, ax                       
    call DispStr ; 调用显示字符串例程   
    jmp $ ; 无限循环   
DispStr:   
    mov ax, BootMessage   
    mov bp, ax ; es:bp = 串地址   
    mov cx, 16 ; cx = 串长度   
    mov ax, 01301h ; ah = 13, al = 01h   
    mov bx, 000ch ; 页号为 0(bh = 0) 黑底红字(bl = 0Ch,高亮)   
    mov dl, 0   
    int 10h ; 10h 号中断   
    ret   
BootMessage:   
    db "Hello, OS world!"   
    times 510-($-$$) db 0 ; 填充剩下的空间,使生成的二进制代码恰好为   
    dw 0xaa55 ; 结束标志  

执行:

nasm boot.asm -o boot.bin
dd if=boot.bin of=a.img
dd if=/dev/zero of=a.img seek=1 bs=512 count=2879
vim bochsrc
###############################################################
# Configuration file for Bochs
###############################################################

# how much memory the emulated machine will have
megs: 32

# filename of ROM images
romimage: file=/usr/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/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=0

# enable key mapping, using US layout as default.
#keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map

3、运行

bochs -f bochsrc

image-20211013102017144

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值