Orange's动手写操作系统-----------第一篇:nasm,bochs环境配置(学习笔记1)

本文记录了配置NASM汇编编译器和Bochs虚拟环境的过程,以支持学习操作系统开发。首先从SourceForge下载并源码安装NASM,然后通过apt-get安装vgabios,接着下载并编译Bochs源文件,创建软盘映像,并将编译的boot.asm代码写入。最后,通过配置.bochsrc文件启动Bochs。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

找完工作,开始学习orange's自己动手写操作系统,希望能够坚持,现在的目标就是好好学习,加油~~~

1:安装nasm汇编编译器:网站下载:http://sourceforge.net/projects/nasm,目前最新版本是,nasm-2.06.tar.gz

    源码安装:

    ~$./configure

    ~$make

    ~$sudo make install

    查看安装版本的:

    :~$ nasm -version
    NASM version 2.06 compiled on Nov 15 2012

2:安装bochs虚拟环境

    1)  先安装vgabios,至于为什么,不太清楚,貌似这个和bochs之间有一定的依赖关系吧

          ~ $sudo apt-get  install     vgabios

    2)下载bochs源文件 http://bochs.sourceforge.net/  本篇文章下载的版本是:bochs-2.6.tar.gz

           开始编译bochs源文件

          ~$ tar vxzf bochs-2.6.tar.gz

          ~$  cd bochs-2.6                        //进去解压后的bochs目录中

          ~$./configure   --enable-debugger    --enable-disasm                 //后边带的参数是为了便于以后调试,在bochs-2.6解压后的文件夹中进行的

          ~$make                                 //同样在bochs-2.6文件夹中进行

          ~$sudo make install    

    3) 创建软盘映像

         在bochs安装好之后,执行

         ~$ bximage                  //出现界面如下,划线部分是是需要自己输入的,某些部分也可以采用默认值

        

        .bochsrc的配置文件稍后附上

3:要编译的代码boot.asm如下:

      

4:编译代码

       ~$ nasm boot.asm   -o    boot.bin                  //boot.bin为生成的文件名

5:引导扇写入软盘:

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

6:相关.bochsrc的配置文件稍后附加上,切记要先进行。bochsrc文件的配置,才能启动

7:bochs启动

      ~$ bochs  出现界面

      

    我们选择2,出现界面如下:

   

   再选择6。出现界面如下:

  终端如下:

 

虚拟bochs

懒得截图了:

终端如下:

<bochs:4> x /64xb 0x7c00
[bochs]:
0x00007c00 <bogus+       0>:    0x8c    0xc8    0x8e    0xd8    0x8e    0xc0    0xe8    0x03
0x00007c08 <bogus+       8>:    0x00    0xe9    0xfd    0xff    0xb8    0x1f    0x7c    0x89
0x00007c10 <bogus+      16>:    0xc5    0xb9    0x10    0x00    0xb8    0x01    0x13    0xbb
0x00007c18 <bogus+      24>:    0x0c    0x00    0xb2    0x00    0xcd    0x10    0xc3    0x48
0x00007c20 <bogus+      32>:    0x65    0x6c    0x6c    0x6f    0x2c    0x20    0x4f    0x53
0x00007c28 <bogus+      40>:    0x20    0x77    0x6f    0x72    0x6c    0x64    0x00    0x00
0x00007c30 <bogus+      48>:    0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
0x00007c38 <bogus+      56>:    0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
<bochs:5> trace-reg on
Register-Tracing enabled for CPU0
<bochs:6> c

bochs界面


基本就这样了,中间出现的错误及其解决稍后加上o(∩∩)o...哈哈

附加:.bochsrc配置文件内容

# You may now use double quotes around pathnames, in case
# your pathname includes spaces.

#=======================================================================
# PLUGIN_CTRL:
# Controls the presence of optional device plugins. These plugins are loaded
# directly with this option and some of them install a config option that is
# only available when the plugin device is loaded. The value "1" means to load
# the plugin and "0" will unload it (if loaded before).
#
# These plugins will be loaded by default (if present): 'biosdev', 'extfpuirq',
# 'gameport', 'iodebug','parallel', 'serial', 'speaker' and 'unmapped'.
#
# These plugins are also supported, but they are usually loaded directly with
# their bochsrc option: 'e1000', 'es1370', 'ne2k', 'pcidev', 'pcipnic', 'sb16',
# 'usb_ohci', 'usb_uhci' and 'usb_xhci'.
#=======================================================================
#plugin_ctrl: unmapped=0, e1000=1 # unload 'unmapped' and load 'e1000'

#=======================================================================
# CONFIG_INTERFACE
#
# The configuration interface is a series of menus or dialog boxes that
# allows you to change all the settings that control Bochs's behavior.
# Depending on the platform there are up to 3 choices of configuration
# interface: a text mode version called "textconfig" and two graphical versions
# called "win32config" and "wx". The text mode version uses stdin/stdout and
# is always compiled in, unless Bochs is compiled for wx only. The choice
# "win32config" is only available on win32 and it is the default there.
# The choice "wx" is only available when you use "--with-wx" on the configure
# command. If you do not write a config_interface line, Bochs will
# choose a default for you.
#
# NOTE: if you use the "wx" configuration interface, you must also use
# the "wx" display library.
#=======================================================================
#config_interface: textconfig
#config_interface: win32config
#config_interface: wx

#=======================================================================
# DISPLAY_LIBRARY
#
# The display library is the code that displays the Bochs VGA screen. Bochs
# has a selection of about 10 different display library implementations for
# different platforms. If you run configure with multiple --with-* options,
# the display_library command lets you choose which one you want to run with.
# If you do not write a display_library line, Bochs will choose a default for
# you.
#
# The choices are:
# x use X windows interface, cross platform
# win32 use native win32 libraries
# carbon use Carbon library (for MacOS X)
# macintosh use MacOS pre-10
# amigaos use native AmigaOS libraries
# sdl use SDL library, cross platform
# svga use SVGALIB library for Linux, allows graphics without X11
# term text only, uses curses/ncurses library, cross platform
# rfb provides an interface to AT&T's VNC viewer, cross platform
# wx use wxWidgets library, cross platform
# nogui no display at all
#
# NOTE: if you use the "wx" configuration interface, you must also use
# the "wx" display library.
#
# Specific options:
# Some display libraries now support specific options to control their
# behaviour. These options are supported by more than one display library:
#
# "gui_debug" - use GTK debugger gui (sdl, x) / Win32 debugger gui (sdl, win32)
# "hideIPS" - disable IPS output in status bar (rfb, sdl, win32, wx, x)
# "nokeyrepeat" - turn off host keyboard repeat (sdl, win32, x)
#
# See the examples below for other currently supported options.
#=======================================================================
#display_library: amigaos
#display_library: carbon
#display_library: macintosh
#display_library: nogui
#display_library: rfb, options="timeout=60" # time to wait for client
#display_library: sdl, options="fullscreen" # startup in fullscreen mode
#display_library: term
#display_library: win32
#display_library: wx
#display_library: x

#=======================================================================
# ROMIMAGE:
# The ROM BIOS controls what the PC does when it first powers on.
# Normally, you can use a precompiled BIOS in the source or binary
# distribution called BIOS-bochs-latest. The ROM BIOS is usually loaded
# starting at address 0xf0000, and it is exactly 64k long. Another option
# is 128k BIOS which is loaded at address 0xe0000.
# You can also use the environment variable $BXSHARE to specify the
# location of the BIOS.
# The usage of external large BIOS images (up to 512k) at memory top is
# now supported, but we still recommend to use the BIOS distributed with
# Bochs. The start address optional, since it can be calculated from image size.
#=======================================================================
romimage: file=$BXSHARE/BIOS-bochs-latest
#romimage: file=bios/seabios-1.6.3.bin
#romimage: file=mybios.bin, address=0xfff80000 # 512k at memory top

#=======================================================================
# CPU:
# This defines cpu-related parameters inside Bochs:
#
# MODEL:
# Selects CPU configuration to emulate from pre-defined list of all
# supported configurations. When this option is used, the CPUID option
# has no effect anymore.
#
# CPU configurations that can be selected:
# -----------------------------------------------------------------
# pentium_mmx Intel Pentium MMX
# amd_k6_2_chomper AMD-K6(tm) 3D processor (Chomper)
# p2_klamath Intel Pentium II (Klamath)
# p3_katmai Intel Pentium III (Katmai)<

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值