- 浏览: 547339 次
- 性别:
- 来自: 上海
-
文章分类
- 全部博客 (231)
- 一个操作系统的实现 (20)
- 汇编(NASM) (12)
- Linux编程 (11)
- 项目管理 (4)
- 计算机网络 (8)
- 设计模式(抽象&封装) (17)
- 数据结构和算法 (32)
- java基础 (6)
- UML细节 (2)
- C/C++ (31)
- Windows (2)
- 乱七八糟 (13)
- MyLaB (6)
- 系统程序员-成长计划 (8)
- POJ部分题目 (10)
- 数学 (6)
- 分布式 & 云计算 (2)
- python (13)
- 面试 (1)
- 链接、装载与库 (11)
- java并行编程 (3)
- 数据库 (0)
- 体系结构 (3)
- C++ template / STL (4)
- Linux环境和脚本 (6)
最新评论
-
chuanwang66:
默默水塘 写道typedef void(*Fun)(void) ...
C++虚函数表(转) -
默默水塘:
typedef void(*Fun)(void);
C++虚函数表(转) -
lishaoqingmn:
写的很好,例子简单明了,将观察者模式都表达了出来。
这里是ja ...
观察者模式——Observer
1、安装nasm和vgabios:[hadoop@sam1 /]$ su root
Password:
[root@sam1 /]# yum install nasm
...[root@sam1 /]# yum install vgabios
...
注意:bochs需要依赖vgabios安装的东西/usr/share/vgabios/VGABIOS-lgpl-latest.bin,所以vgabios需要先安装!
2、安装可调试版bochs(从源代码安装):
注意:我先开始尝试安装Bochs 2.6等新版本都会出问题,最后还是安装了书上提到的bochs 2.3.5,configure/make/make install就一切正常了。
1)到bochs官方主页http://bochs.sourceforge.net/ ,有个Older News条目,进入当前最新版本Bochs 2.4.6
下载源代码包bochs-2.4.6.tar.gz
2)
tar vxzf bochs-2.4.6.tar.gz -->解压
cd bochs-2.4.6
./configure --enable-debugger --enable-disasm -->开启调试和反汇编功能
make
make install -->出现make: *** [install_bin] Error 1
(解决方法:命令前加上sudo就行,就是sudo make install)
2、制作引导扇区boot.asm:
1)桌面上(/home/hadoop/Desktop)新建OSImpl文件夹,在OSImpl下新建文件boot.asm,其内容如下
org 07c00h
mov ax,cs
mov ds,ax
mov es,ax
call DispStr
jmp $
DispStr:
mov ax, BootMessage
mov bp, ax
mov cx, 16
mov ax, 01301h
mov bx, 000ch
mov dl, 0 int 10h
ret
BootMessage: db "Hello, OS world!"
times 510-($-$$) db 0
dw 0xaa55
2)汇编boot.asm文件
[hadoop@sam1 OSImpl]$ pwd
/home/hadoop/Desktop/OSImpl
[hadoop@sam1 OSImpl]$ ls
bochs-2.4.6 boot.asm
[hadoop@sam1 OSImpl]$ nasm boot.asm -o boot.bin
[hadoop@sam1 OSImpl]$ ls
bochs-2.4.6 boot.asm boot.bin
3、创建软盘镜像文件a.img,把boot.bin逐字节拷贝进去
[hadoop@sam1 OSImpl]$ cd bochs-2.4.6/
[hadoop@sam1 bochs-2.4.6]$ ./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]
Writing: [] Done.
I wrote 1474560 bytes to a.img.
The following line should appear in your bochsrc:
floppya: image="a.img", status=inserted
[hadoop@sam1 bochs-2.4.6]$ dd if=../boot.bin of=./a.img bs=512 count=1 conv=notrunc
-->虚拟机中需要指定conv这项,真实的机器中软盘不会被截断
1+0 records in
1+0 records out
512 bytes (512 B) copied, 6.3313e-05 s, 8.1 MB/s
4、创建配置文件.bochsrc,修改相关配置
如果使用yum install vgabios bochs bochs-x bximage 方式安装bochs,bochsrc-sample.txt作为配置文件的模板会被安装[hadoop@sam1 OSImpl]$ rpm -ql bochs | grep bochsrc-sample.txt
我这里用源代码包安装的,按照《Orange'S 一个操作系统的实现》P11配置即可:
[hadoop@sam1 bochs-2.4.6]$ gedit .bochsrc -->在工程文件夹下创建.bochsrc
####################################.bochsrc-start###################################
megs:32
romimage:file=/usr/share/bochs/BIOS-bochs-latest
#书上使用这个: vgaromimage:file=/usr/share/vgabios/vgabios.bin
#但通过ls -l /usr/share/vgabios/vgabios.bin发现并不存在,换成/usr/share/vgabios/VGABIOS-lgpl-latest.bin即可
vgaromimage:file=/usr/share/vgabios/VGABIOS-lgpl-latest.bin
floppya: 1_44=a.img, status=inserted
boot:floppy
log:bochsout.txt
#######################################.bochsrc-end#################################
5、启动bochs,运行Hello,OS world示例
[hadoop@sam1 bochs-2.4.6]$ ./bochs
========================================================================
Bochs x86 Emulator 2.4.6
Build from CVS snapshot, on February 22, 2011
Compiled at May 19 2011, 22:34:01
========================================================================
00000000000i[ ] reading configuration from .bochsrc
------------------------------
Bochs Configuration: Main Menu
------------------------------
This is the Bochs Configuration Interface, where you can describe the
machine that you want to simulate. Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found. When you are satisfied with the configuration, go
ahead and start the simulation.
You can also start bochs with the -q option to skip these menus.
1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now
Please choose one: [6] 2
00000000000i[ ] Screen mode changed to none
What is the configuration file name?
To cancel, type 'none'. [.bochsrc]
00000000000i[ ] reading configuration from .bochsrc
------------------------------
Bochs Configuration: Main Menu
------------------------------
This is the Bochs Configuration Interface, where you can describe the
machine that you want to simulate. Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found. When you are satisfied with the configuration, go
ahead and start the simulation.
You can also start bochs with the -q option to skip these menus.
1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now
Please choose one: [6]
*********************************************************************************
00000000000i[ ] installing x module as the Bochs GUI
00000000000i[ ] using log file bochsout.txt
Next at t=0
(0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b ; ea5be000f0
<bochs:1> b 0x7c00
<bochs:2> c
(0) Breakpoint 1, 0x00007c00 in ?? ()
Next at t=12943100
(0) [0x0000000000007c00] 0000:7c00 (unk. ctxt): mov ax, cs ; 8cc8
<bochs:3> info cpu
eax: 0x0000aa55 43605
ecx: 0x00090000 589824
edx: 0x00000000 0
ebx: 0x00000000 0
esp: 0x0000ffd6 65494
ebp: 0x00000000 0
esi: 0x000e34e0 931040
edi: 0x0000ffac 65452
eip: 0x00007c00
eflags 0x00000082: id vip vif ac vm rf nt IOPL=0 of df if tf SF zf af pf cf
status word: 0x0000: b c3 TOS0 c2 c1 c0 es sf pe ue oe ze de ie
control word: 0x0040: inf RC_NEAREST PC_32 pm um om zm dm im
tag word: 0x5555
operand: 0x0000
fip: 0x00000000
fcs: 0x0000
fdp: 0x00000000
fds: 0x0000
=>FP0 ST0(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP1 ST1(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP2 ST2(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP3 ST3(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP4 ST4(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP5 ST5(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP6 ST6(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP7 ST7(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
MXCSR: 0x00001f80: ule fuz RC:0 PM UM OM ZM DM IM daz pe ue oe ze de ie
XMM[00]: 00000000:00000000:00000000:00000000
XMM[01]: 00000000:00000000:00000000:00000000
XMM[02]: 00000000:00000000:00000000:00000000
XMM[03]: 00000000:00000000:00000000:00000000
XMM[04]: 00000000:00000000:00000000:00000000
XMM[05]: 00000000:00000000:00000000:00000000
XMM[06]: 00000000:00000000:00000000:00000000
XMM[07]: 00000000:00000000:00000000:00000000
<bochs:4> x /64xb 0x7c00
[bochs]:
0x00007c00 <bogus+ 0>: 0x8c 0xc8 0x8e 0xd8 0x8e 0xc0 0xe8 0x02
0x00007c08 <bogus+ 8>: 0x00 0xeb 0xfe 0xb8 0x1e 0x7c 0x89 0xc5
0x00007c10 <bogus+ 16>: 0xb9 0x10 0x00 0xb8 0x01 0x13 0xbb 0x0c
0x00007c18 <bogus+ 24>: 0x00 0xb2 0x00 0xcd 0x10 0xc3 0x48 0x65
0x00007c20 <bogus+ 32>: 0x6c 0x6c 0x6f 0x2c 0x20 0x4f 0x53 0x20
0x00007c28 <bogus+ 40>: 0x77 0x6f 0x72 0x6c 0x64 0x21 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> n
Next at t=12943101
(0) [0x0000000000007c02] 0000:7c02 (unk. ctxt): mov ds, ax ; 8ed8
<bochs:6> trace-reg on
Register-Tracing enabled for CPU0
<bochs:7> n
Next at t=12943102
eax: 0x00000000 0
ecx: 0x00090000 589824
edx: 0x00000000 0
ebx: 0x00000000 0
esp: 0x0000ffd6 65494
ebp: 0x00000000 0
esi: 0x000e34e0 931040
edi: 0x0000ffac 65452
eip: 0x00007c04
eflags 0x00000082: id vip vif ac vm rf nt IOPL=0 of df if tf SF zf af pf cf
(0) [0x0000000000007c04] 0000:7c04 (unk. ctxt): mov es, ax ; 8ec0
<bochs:8> c
此时出现Hello, OS world! 的红色字样!
Password:
[root@sam1 /]# yum install nasm
...[root@sam1 /]# yum install vgabios
...
注意:bochs需要依赖vgabios安装的东西/usr/share/vgabios/VGABIOS-lgpl-latest.bin,所以vgabios需要先安装!
2、安装可调试版bochs(从源代码安装):
注意:我先开始尝试安装Bochs 2.6等新版本都会出问题,最后还是安装了书上提到的bochs 2.3.5,configure/make/make install就一切正常了。
1)到bochs官方主页http://bochs.sourceforge.net/ ,有个Older News条目,进入当前最新版本Bochs 2.4.6
下载源代码包bochs-2.4.6.tar.gz
2)
tar vxzf bochs-2.4.6.tar.gz -->解压
cd bochs-2.4.6
./configure --enable-debugger --enable-disasm -->开启调试和反汇编功能
make
make install -->出现make: *** [install_bin] Error 1
(解决方法:命令前加上sudo就行,就是sudo make install)
2、制作引导扇区boot.asm:
1)桌面上(/home/hadoop/Desktop)新建OSImpl文件夹,在OSImpl下新建文件boot.asm,其内容如下
org 07c00h
mov ax,cs
mov ds,ax
mov es,ax
call DispStr
jmp $
DispStr:
mov ax, BootMessage
mov bp, ax
mov cx, 16
mov ax, 01301h
mov bx, 000ch
mov dl, 0 int 10h
ret
BootMessage: db "Hello, OS world!"
times 510-($-$$) db 0
dw 0xaa55
2)汇编boot.asm文件
[hadoop@sam1 OSImpl]$ pwd
/home/hadoop/Desktop/OSImpl
[hadoop@sam1 OSImpl]$ ls
bochs-2.4.6 boot.asm
[hadoop@sam1 OSImpl]$ nasm boot.asm -o boot.bin
[hadoop@sam1 OSImpl]$ ls
bochs-2.4.6 boot.asm boot.bin
3、创建软盘镜像文件a.img,把boot.bin逐字节拷贝进去
[hadoop@sam1 OSImpl]$ cd bochs-2.4.6/
[hadoop@sam1 bochs-2.4.6]$ ./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]
Writing: [] Done.
I wrote 1474560 bytes to a.img.
The following line should appear in your bochsrc:
floppya: image="a.img", status=inserted
[hadoop@sam1 bochs-2.4.6]$ dd if=../boot.bin of=./a.img bs=512 count=1 conv=notrunc
-->虚拟机中需要指定conv这项,真实的机器中软盘不会被截断
1+0 records in
1+0 records out
512 bytes (512 B) copied, 6.3313e-05 s, 8.1 MB/s
4、创建配置文件.bochsrc,修改相关配置
如果使用yum install vgabios bochs bochs-x bximage 方式安装bochs,bochsrc-sample.txt作为配置文件的模板会被安装[hadoop@sam1 OSImpl]$ rpm -ql bochs | grep bochsrc-sample.txt
我这里用源代码包安装的,按照《Orange'S 一个操作系统的实现》P11配置即可:
[hadoop@sam1 bochs-2.4.6]$ gedit .bochsrc -->在工程文件夹下创建.bochsrc
####################################.bochsrc-start###################################
megs:32
romimage:file=/usr/share/bochs/BIOS-bochs-latest
#书上使用这个: vgaromimage:file=/usr/share/vgabios/vgabios.bin
#但通过ls -l /usr/share/vgabios/vgabios.bin发现并不存在,换成/usr/share/vgabios/VGABIOS-lgpl-latest.bin即可
vgaromimage:file=/usr/share/vgabios/VGABIOS-lgpl-latest.bin
floppya: 1_44=a.img, status=inserted
boot:floppy
log:bochsout.txt
#######################################.bochsrc-end#################################
5、启动bochs,运行Hello,OS world示例
[hadoop@sam1 bochs-2.4.6]$ ./bochs
========================================================================
Bochs x86 Emulator 2.4.6
Build from CVS snapshot, on February 22, 2011
Compiled at May 19 2011, 22:34:01
========================================================================
00000000000i[ ] reading configuration from .bochsrc
------------------------------
Bochs Configuration: Main Menu
------------------------------
This is the Bochs Configuration Interface, where you can describe the
machine that you want to simulate. Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found. When you are satisfied with the configuration, go
ahead and start the simulation.
You can also start bochs with the -q option to skip these menus.
1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now
Please choose one: [6] 2
00000000000i[ ] Screen mode changed to none
What is the configuration file name?
To cancel, type 'none'. [.bochsrc]
00000000000i[ ] reading configuration from .bochsrc
------------------------------
Bochs Configuration: Main Menu
------------------------------
This is the Bochs Configuration Interface, where you can describe the
machine that you want to simulate. Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found. When you are satisfied with the configuration, go
ahead and start the simulation.
You can also start bochs with the -q option to skip these menus.
1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now
Please choose one: [6]
*********************************************************************************
00000000000i[ ] installing x module as the Bochs GUI
00000000000i[ ] using log file bochsout.txt
Next at t=0
(0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b ; ea5be000f0
<bochs:1> b 0x7c00
<bochs:2> c
(0) Breakpoint 1, 0x00007c00 in ?? ()
Next at t=12943100
(0) [0x0000000000007c00] 0000:7c00 (unk. ctxt): mov ax, cs ; 8cc8
<bochs:3> info cpu
eax: 0x0000aa55 43605
ecx: 0x00090000 589824
edx: 0x00000000 0
ebx: 0x00000000 0
esp: 0x0000ffd6 65494
ebp: 0x00000000 0
esi: 0x000e34e0 931040
edi: 0x0000ffac 65452
eip: 0x00007c00
eflags 0x00000082: id vip vif ac vm rf nt IOPL=0 of df if tf SF zf af pf cf
status word: 0x0000: b c3 TOS0 c2 c1 c0 es sf pe ue oe ze de ie
control word: 0x0040: inf RC_NEAREST PC_32 pm um om zm dm im
tag word: 0x5555
operand: 0x0000
fip: 0x00000000
fcs: 0x0000
fdp: 0x00000000
fds: 0x0000
=>FP0 ST0(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP1 ST1(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP2 ST2(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP3 ST3(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP4 ST4(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP5 ST5(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP6 ST6(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
FP7 ST7(0): raw 0x0000:0000000000000000 (0.0000000000) (ZERO)
MXCSR: 0x00001f80: ule fuz RC:0 PM UM OM ZM DM IM daz pe ue oe ze de ie
XMM[00]: 00000000:00000000:00000000:00000000
XMM[01]: 00000000:00000000:00000000:00000000
XMM[02]: 00000000:00000000:00000000:00000000
XMM[03]: 00000000:00000000:00000000:00000000
XMM[04]: 00000000:00000000:00000000:00000000
XMM[05]: 00000000:00000000:00000000:00000000
XMM[06]: 00000000:00000000:00000000:00000000
XMM[07]: 00000000:00000000:00000000:00000000
<bochs:4> x /64xb 0x7c00
[bochs]:
0x00007c00 <bogus+ 0>: 0x8c 0xc8 0x8e 0xd8 0x8e 0xc0 0xe8 0x02
0x00007c08 <bogus+ 8>: 0x00 0xeb 0xfe 0xb8 0x1e 0x7c 0x89 0xc5
0x00007c10 <bogus+ 16>: 0xb9 0x10 0x00 0xb8 0x01 0x13 0xbb 0x0c
0x00007c18 <bogus+ 24>: 0x00 0xb2 0x00 0xcd 0x10 0xc3 0x48 0x65
0x00007c20 <bogus+ 32>: 0x6c 0x6c 0x6f 0x2c 0x20 0x4f 0x53 0x20
0x00007c28 <bogus+ 40>: 0x77 0x6f 0x72 0x6c 0x64 0x21 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> n
Next at t=12943101
(0) [0x0000000000007c02] 0000:7c02 (unk. ctxt): mov ds, ax ; 8ed8
<bochs:6> trace-reg on
Register-Tracing enabled for CPU0
<bochs:7> n
Next at t=12943102
eax: 0x00000000 0
ecx: 0x00090000 589824
edx: 0x00000000 0
ebx: 0x00000000 0
esp: 0x0000ffd6 65494
ebp: 0x00000000 0
esi: 0x000e34e0 931040
edi: 0x0000ffac 65452
eip: 0x00007c04
eflags 0x00000082: id vip vif ac vm rf nt IOPL=0 of df if tf SF zf af pf cf
(0) [0x0000000000007c04] 0000:7c04 (unk. ctxt): mov es, ax ; 8ec0
<bochs:8> c
此时出现Hello, OS world! 的红色字样!
发表评论
-
(第三章 8 )特权级——保护模式的特权级检查(DPL,RPL,CPL, 一致代码段,非一致代码段)
2013-03-20 11:14 2376特权级是保护模式下一个重要的概念,CPL,RPL和 ... -
(第6章 1)最简单的进程
2012-10-11 10:56 1047第一步——ring0 --> ring1 ... -
(第4章 2)突破512字节的限制
2012-09-15 11:40 2824一、代码 ... -
(第4章 1)软盘结构及其数据读取
2012-09-14 21:59 1955参考资料: http://blog.cs ... -
(第三章 12)中断
2012-09-11 20:20 1060一、中断和8259A中断控制器 1. ... -
(第三章 8 )特权级——CPL、DPL、RPL
2012-07-11 10:02 2459很久以后,等我大量翻阅关于“保护模式的特权级检 ... -
(第三章 0)保护模式如何“保护”
2012-03-14 07:59 1113IA32中“保护模式”的“保护”二字理解:(P48) ... -
(第一、二章)nasm的汇编和反汇编
2012-02-27 13:36 4987nasm的汇编和反汇编 步骤: 1. 汇编(bo ... -
(第三章 14)克勤克俭用内存——初始化页目录表、页表,开启分页机制
2011-07-22 11:30 249在启动分页机制SetupPaging之前,先调用了Di ... -
(第三章 13)克勤克俭用内存——查看内存块
2011-07-22 09:25 143[SECTION .data1] ALIGN 32 ... -
(第三章 12)克勤克俭用内存——显示字符串
2011-07-21 16:25 116DispStr调用方法: [SECTION . ... -
(第三章 11)根据自己内存情况 使用分页机制
2011-06-11 15:51 1500一、查看内存分布情况 设置“页目录表”和“页 ... -
参考博客-还有哪些人也在看这本书
2011-06-10 22:46 1403这位很详细: http://www.cnblogs.com/ ... -
(第三章 10)“代码段间跳转” 和 “访问数据段”
2011-06-10 15:40 1392下面说明代码段和数据段的访问: 一、代码段间跳转 ... -
(第三章 9)通过调用门进行有特权级变换的转移(二)
2011-06-08 11:29 191本文展示《(第三章 9)通过调用门进行有特权级变换的转移(一) ... -
(第三章 9)“调用门” 和 “利用调用门在高低特权级的转移”
2011-06-08 10:34 2702在此之前,先要熟悉汇编指令“长/短jmp”、“长/短c ... -
(第三章 7)LDT
2011-06-06 09:49 1528先展示一下效果图: 直接看代码: ... -
(第三章 6)保护模式下,读写大地址内存 & 从32位保护模式跳回16位实模式(二)
2011-06-06 09:15 1493三、关于保护模式和实 ... -
(第三章 5)保护模式下,读写大地址内存 & 从32位保护模式跳回16位实模式(一)
2011-06-05 13:53 2093一、主要功能 ... -
(第三章 3)数据段/代码段描述符
2011-06-05 11:53 2283一、宏定义和属性常量 (代码段/数据段描述符见P32;门描述 ...
相关推荐
在80x86 IBM PC 兼容计算机上用一张软盘启动引导程序,最后打印出下面的字样: Hello world! The current time is hh:mm:ss.(动态输出时间) ...5、是写操作系统的第一步!! 6、可执行源码和详细教程。
第1章 马上动手写一个最小的"操作系统"1 1.1 准备工作1 1.2 10分钟完成的操作系统1 1.3 Boot Sector3 1.4 代码解释3 1.5 水面下的冰山5 1.6 回顾6 第2章 搭建你的工作环境7 2.1 虚拟计算机(Virtual PC)7 ...
第1章 马上动手写一个最小的“操作系统”1 1.1 准备工作1 1.2 10分钟完成的操作系统1 1.3 Boot Sector3 1.4 代码解释3 1.5 水面下的冰山5 1.6 回顾6 第2章 搭建你的工作环境7 2.1 虚拟计算机(Virtual PC)7 2.1.1 ...
在实验中,你需要安装Bochs模拟器,并学会使用它来创建硬盘配置和运行程序。Bochs提供了强大的调试功能,通过debug指令可以深入理解程序执行的每一步。编写Hello World程序不仅可以帮助你熟悉汇编语法,还能让你直观...
第1章 马上动手写一个最小的“操作系统”1 1.1 准备工作1 1.2 10分钟完成的操作系统1 1.3 Boot Sector3 1.4 代码解释3 1.5 水面下的冰山5 1.6 回顾6 第2章 搭建你的工作环境7 2.1 虚拟计算机(Virtual PC)7 2.1.1 ...
引导程序是在计算机启动过程中由BIOS加载的第一个程序,用于初始化系统并加载操作系统内核。其特点包括: 1. **大小限制**:引导程序必须恰好512字节大小。 2. **结束标志**:引导程序的最后两个字节必须是AA55H...
这是书中的源代码:“如何制作一个简单的...Eg: nasm boot_helloworld.asm -f bin -o boot_helloworld.bin 中银国际使用: QEMU 用法: qemu-system-i386 [bin_filename] Eg: qemu-system-i386 boot_helloworld.bin
使用NASM编译`boot.asm`生成`boot.bin`,然后利用`dd`或`rawrite`将生成的二进制文件写入软盘的第一个扇区,从而创建了一个引导盘。 5. **运行与验证**: - 完成上述步骤后,将软盘插入软驱,重新启动计算机,...
NASM编译器将汇编代码编译成二进制格式的boot.bin文件,然后通过软盘绝对扇区读写工具将该文件写入软盘的第一个扇区,制作成一个可以引导的软盘。 完成引导扇区的编写和制作后,可以将这个引导盘放入计算机的软驱中...
目录 第一篇 x86 基础 第1 章数与数据类型2 1.1 数 2 1.1.1 数字 2 1.1.2 二进制数 3 1.1.3 二进制数的排列 3 1.1.4 十六进制数 5 1.1.5 八进制数与十进制数 5 1.2 数据类型 6 1.2.1 integer 数 6 1.2.2 floating-...
目录 第一篇 x86 基础 第1 章数与数据类型2 1.1 数 2 1.1.1 数字 2 1.1.2 二进制数 3 1.1.3 二进制数的排列 3 1.1.4 十六进制数 5 1.1.5 八进制数与十进制数 5 1.2 数据类型 6 1.2.1 integer 数 6 1.2.2 floating-...
目录 第一篇 x86 基础 第1 章数与数据类型2 1.1 数 2 1.1.1 数字 2 1.1.2 二进制数 3 1.1.3 二进制数的排列 3 1.1.4 十六进制数 5 1.1.5 八进制数与十进制数 5 1.2 数据类型 6 1.2.1 integer 数 6 1.2.2 floating-...
目录 第一篇 x86 基础 第1 章数与数据类型2 1.1 数 2 1.1.1 数字 2 1.1.2 二进制数 3 1.1.3 二进制数的排列 3 1.1.4 十六进制数 5 1.1.5 八进制数与十进制数 5 1.2 数据类型 6 1.2.1 integer 数 6 1.2.2 floating-...
- **引导块**:通常位于硬盘的第一个扇区,包含一段小程序,用于检测操作系统所在的分区并加载相应的引导加载程序。 - **魔法数字**:在MBR中有一个特定的“魔法数字”(通常是`0xAA55`),用来确认该扇区是否为有效的...
- **示例1:简单的Hello World程序** 1. 初始化数据段,设置输出字符串。 2. 使用`mov`指令将字符串地址传给寄存器。 3. 调用`int 21h`(DOS中断)来显示字符串。 4. 使用`ret`指令结束程序。 - **示例2:实现两...
在计算机系统启动时,首先读取硬盘上的第一个扇区,即引导扇区(也称为启动扇区或引导记录)。这一扇区包含了引导加载程序(Bootloader)的代码,其主要任务是将操作系统内核加载到内存中并执行。 在《Playing.with...
6. **模拟器/虚拟机**:为了在不同硬件平台上测试汇编代码,模拟器如QEMU或Bochs能够模拟处理器和其他硬件,使得汇编程序能够在非目标平台上运行。 7. **汇编语言基础**:学习汇编语言时,需要理解基本的指令集,如...
- **Bochs**:用于模拟PC运行环境。 #### 五、教学资料 - **OSDev Wiki**:包含有关操作系统开发的相关资源,其中也包含了汇编语言的教学内容。 #### 六、建议与注意项 1. **实践**:汇编语言的学习需要大量的...