首先去bochs的官网

http://bochs.sourceforge.net/

下载最新的程序,我直接下的是bochs-2.4.tar.gz

tar zxvf bochs-2.4.tar.gz

./configure

如果要调试功能的话,可查看configure文件做相应调整

--enable-debugger                 compile in support for Bochs internal debugger

--enable-disasm                   compile in support for disassembler

--enable-debugger-gui             compile in support for Bochs internal debugger GUI

--with-sdl                        use SDL libraries

网上说要加最后一个暂时没有明白其意。

make

./bochs  运行BOCHS运行需要.bochsrc文件,在LINUX下以.开头的文件都是隐藏文件

l. 可查看这些文件。

vi .bochsrc

# how much memory the emulated machine will have

megs: 32# filename of ROM images

romimage:file=$BXSHARE/BIOS-bochs-latest

#注意上面这一行,2.3.5以后的后面不能加,address=0xf0000  否则会出现

#Message: ROM: System BIOS must end at 0xfffff 错误的  这个后面会解释

#romimage: file=mybios.bin, address=0xfff80000 # 512k at memory topvgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest

# what disk images will be used

floppya: 1_44=hello.img, status=inserted#ata0-master: type=disk, mode=flat, path="30M.sample"# hard disk

#ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14

#ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15

#ata2: enabled=0, ioaddr1=0x1e8, ioaddr2=0x3e0, irq=11

#ata3: enabled=0, ioaddr1=0x168, ioaddr2=0x360, irq=9boot: floppy

#boot: diskmegs: 32 是说内存是32M

floppya: 1_44=a.img, status=inserted 指定了软盘映像文件

boot: floppy 从软盘启动。从http://bochs.sourceforge.net/下载nasm

我下的是nasm-2.05.01.tar.gz

tar zxvf nasm-2.05.01.tar.gz

cd nasm-2.05.01

./configure

make

make installmkdir helloworld

cd helloworld

vi hello.asm

;hello.asm

org 07c00h

LABEL_START:

mov ax,cs

mov ds,ax

mov es,ax

mov ax,0b800h

mov gs,ax

mov ah,0ch

mov al,'H'

mov [gs:0],ax

jmp $./nasm ./helloworld/hello.asm  -o ./helloworld/hello.bin进入bochs目录

./bximage

========================================================================

bximage

Disk Image Creation Tool for Bochs

$Id: bximage.c,v 1.34 2009/04/14 09:45:22 sshwarts Exp $

========================================================================

Do you want to create a floppy disk image or a hard disk image?

Please type hd or fd. [hd] fd

Choose the size of floppy disk image to create, in megabytes.

Please type 0.16, 0.18, 0.32, 0.36, 0.72, 1.2, 1.44, 1.68, 1.72, or 2.88.

[1.44]

I will create a floppy image with

cyl=80

heads=2

sectors per track=18

total sectors=2880

total bytes=1474560

What should I name the image?

[a.img] hello.img

Writing: [] Done.

I wrote 1474560 bytes to hello.img.

The following line should appear in your bochsrc:

floppya: image="hello.img", status=inserted把bin写入img中

dd if=/nasm-2.05.01/helloworld/hello.bin of=hello.img bs=512 count=1 conv=notrunc

读入了 0+1 个块

输出了 0+1 个块bochs -q -f .bochsrc 运行我们的OS

出现如下错误

Bochs is exiting with the following message:

[BIOS ] No bootable device.查看生成的hello.bin大小

ls -al hello.bin

-rw-r--r--    1 root     900            22  5月 20 11:45 hello.bin

大小为22byte

我们要把它们弄成512byte的

在hello.asm最后添加

times 510-($-$$) db 0 ; 填充剩下的空间,使生成的二进制代码恰好为512字节

dw        0xaa55      ;这个是结束标志符

再用nasm编译生成hello.bin

再写入到hello.img便可以了。

然后执行

bochs -q -f .bochsrc

便可以看到红色的H字样了ps:

若出现Message: ROM: System BIOS must end at 0xfffff 错误的原因如下:

In previous versions of Bochs the BIOS size was 64k and you always had to

specify the start address at 0xf0000. Starting with release 2.2.5 Bochs

supports BIOS images up to 512k and it's no longer necessary to specify the

start address if the BIOS ends at memory top

就是不要再指定address了。当然要显示Hello world可用以下这个

org 07c00h

mov        ax, cs;数据传送指令,将代码段寄存器cs的内容赋给通用寄存器ax

mov        ds, ax;使数据段与代码段在同一个段

mov        es, ax;使附加段与代码段在同一个段

call        DispStr

jmp        $ ;$表示当前地址,无限循环

DispStr:

mov        ax, BootMessage

mov        bp, ax ;es:bp=串地址

mov        cx, 15 ;串长度

mov        ax, 01301h  ;ah=13h, al=01h 视频中断13h号功能:写字符串;AL=01H,表示写完字符串后,更新光标位置

mov        bx, 000ch   ;页号为0(bh=0) 黑底红字(bl=0ch,高亮)

mov        dl, 0 ;DH、DL=写串的光标位置,DH=行号,DL=列号

int        10h

ret

BootMessage:        db "Hello,World OS!"

times 510-($-$$) db 0 ; 填充剩下的空间,使生成的二进制代码恰好为512字节

dw        0xaa55times 510-($-$$) db 0

This reads: Times 510-(Start of this Instruction - Start of program) with 0's

$ stands for start of the instruction

$$ stands for start of the program

dw 0xAA55For some reason the signature has to be written this way round!

This fills the last to bytes of the boot loader with 55AA (this is a hex number)

Without this signature the BIOS won't recognise this as a bootable disk!

bochs linux 键盘乱码,linux 下Bochs的安装及问题解决相关推荐

  1. linux键盘修复,linux和macos_如何在macOS和Linux上修复Corsair鼠标和键盘问题

    linux和macos_如何在macOS和Linux上修复Corsair鼠标和键盘问题 linux和macos_如何在macOS和Linux上修复Corsair鼠标和键盘问题 linux和macos ...

  2. linux xfs yum,Redhat下XFS的安装

    一.XFS 简介及特性 XFS 最初是由 Silicon Graphics,Inc. 于 90 年代初开发的.那时,SGI 发现他们的现有文件系统(existing filesystem,EFS)正在 ...

  3. nwjs sdk linux x64,Ubuntu环境下的nwjs安装及使用教程

    需求:通过nwjs实现一个可以全屏显示,防止用户退出浏览器的演示用app 一.安装Node.js sudo apt-get install nodejs sudo apt-get install np ...

  4. linux ubuntu 12.04 下默认是安装了openjdk的

    ubuntu 12.04 下默认是安装了openjdk的,不过这个jdk问题比较多,因为你甚至无法启动Eclipse,所以还是需要自己安装jdk的. 1.下载jdk6 jdk6下载地址为:http:/ ...

  5. eclipse linux windows 乱码,Ubuntu下Eclipse打开Windows下的工程文件乱码解决办法

    Eclipse在Windows下默认使用的是GBK(包括GB2312)编码,而在Linux系统默认使用的是UTF-8编码,并且eclipse编码设置下拉列表不提供GBK编码可选项.如果eclipse打 ...

  6. linux python乱码_linux下python中文乱码解决方案详解

    linux下python中文乱码解决方案详解 发布时间:2020-09-06 20:24:49 来源:脚本之家 阅读:68 1. 场景描述 linux服务器下安装了Anaconda3,执行Pyhton ...

  7. linux mp3 乱码,linux下mp3乱码终极解决方案

    只需要把mp3标签里面用gbk.gb18030.big5等编码存储的中文内容修改为Unicode编码,那么基本上所有Linux下的播放器都能正常识别mp3标签了. 关于mp3编码的转换,介绍一个工具- ...

  8. linux键盘模拟程序,linux下模拟键盘的几种方法

    1.使用GTK中的GdkEvent GdkEvent *event; event = gdk_event_new (GDK_KEY_PRESS);              //按键按下 event- ...

  9. linux mp3 乱码,Linux下MP3的TAG乱码问题解决方法

    复制代码 代码如下: sudo apt-get install python-mutagen 然后使用mid3iconv工具 Usage: mid3iconv [OPTION] [FILE]... M ...

  10. linux+wine乱码,Ubuntu下Wine乱码解决方法与中文支持

    由于这段时间安装了Ubuntu 9.04 x64的系统,也碰到了很多问题,收集起来以便方便使用 安装 wine ubuntu 官方自带了 wine , 但是推荐用 winehq 官方提供的最新版本 w ...

最新文章

  1. Java 调用Oracle的存储过程
  2. Assembler NASM 指令说明
  3. c# 注册表操作,创建,删除,修改,判断节点是否存在
  4. JavaFX 的 UI 控件集 ControlsFX
  5. 使用Drools跟踪输出
  6. 史上最浅显易懂的Git教程3 分支管理
  7. pandas(一) Series和DataFrame
  8. 音乐app项目开发(一)
  9. 10分钟学会 Qt 扁平化界面(qss 使用)
  10. j3455linux网卡不亮,最新J3455主板直接安装黑群晖的若干问题解决办法
  11. 攻防世界-re-for-50-plz-50
  12. 前端框架Layui学习五:弹出层和数据表格
  13. 为什么docker容器启动不了?
  14. 【毕业设计】机器视觉答题卡识别系统 - python 深度学习
  15. HTML中如何插入空格,HTML空格代码,多种HTML空格写法
  16. 【笔记】机器翻译学术论文写作方法和技巧(作者:清华大学 刘洋)
  17. Altium Designer(二)电阻、电容 模型的创建
  18. 数学专业英语--函数部分
  19. vscode远程连接服务器
  20. Windows Update失败 还原更改。请勿关闭计算机

热门文章

  1. java对接有赞云一(引入仓库)
  2. Java 8特性之Stream流,用心看这篇就够了【重点】
  3. MSP430 F5529的按钮控制led灯亮灭程序代码——按一下亮一下,再按一下暗
  4. C语言中结构体数组怎么打印出来,怎么才能把结构体里面的二维数组打印出来?...
  5. 撞车之后,不要傻里傻气的,有车没车的都收藏起来吧,真的很有用!
  6. Wikidata 数据包下载+格式转换+入库MySQL
  7. Starting namenodes on [] 为空
  8. DAX:SUMMARIZE的秘密
  9. 7-88 计算分段函数[2] (10 分)
  10. 职高女孩从开餐厅起家,如今资产过亿元