操作系统:使用AT&T实现引导扇区
2016-09-09 17:21
295 查看
参考学习于渊的书箱时,里面都是用nasm来写的,而自己更熟悉和使用AT&T的语法,心想用AT&T来实现一下,这个过程是十分漫长与痛苦的,但也收获颇丰。
.section .text
.globl _start
_start:
movw %cs, %ax
movw %ax, %ds
movw %ax, %es
call DispStr
loop1:
jmp loop1
DispStr:
movw $BootMessage, %ax
movw %ax, %bp
movw $0x10, %cx
movw $0x1301, %ax
movw $0xc, %bx
movb $0, %dl
int $0x10
ret
BootMessage:
.ascii "Hello, MN world!"
.org 510
.word 0xAA55
如果理解有些难,请先参考我的另一篇文章《操作系统:实现引导扇区》 http://blog.csdn.net/furzoom/article/details/52485090
首先.code16含义为16位运行模式,参考http://web.mit.edu/gnu/doc/html/as_18.html#SEC209
While GAS normally writes only "pure" 32-bit i386 code, it has limited support for writing code to run in real mode or in 16-bit protected mode code segments. To do this, insert a `.code16' directive before the assembly language
instructions to be run in 16-bit mode. You can switch GAS back to writing normal 32-bit code with the `.code32' directive.
Bochs运行结果:
关于.code16指令:http://web.mit.edu/gnu/doc/html/as_18.html#SEC209
1. 引导扇区代码
.code16.section .text
.globl _start
_start:
movw %cs, %ax
movw %ax, %ds
movw %ax, %es
call DispStr
loop1:
jmp loop1
DispStr:
movw $BootMessage, %ax
movw %ax, %bp
movw $0x10, %cx
movw $0x1301, %ax
movw $0xc, %bx
movb $0, %dl
int $0x10
ret
BootMessage:
.ascii "Hello, MN world!"
.org 510
.word 0xAA55
如果理解有些难,请先参考我的另一篇文章《操作系统:实现引导扇区》 http://blog.csdn.net/furzoom/article/details/52485090
首先.code16含义为16位运行模式,参考http://web.mit.edu/gnu/doc/html/as_18.html#SEC209
While GAS normally writes only "pure" 32-bit i386 code, it has limited support for writing code to run in real mode or in 16-bit protected mode code segments. To do this, insert a `.code16' directive before the assembly language
instructions to be run in 16-bit mode. You can switch GAS back to writing normal 32-bit code with the `.code32' directive.
2. 编译
as -o boot.o boot.s ld -Ttext=0x7c00 --oformat binary -o boot.bin boot.o dd if=/dev/zero of=emptydisk.img bs=512 count=2880 dd if=boot.bin of=Finix.img bs=512 count=1 dd if=emptydisk.img of=Finix.img skip=1 seek=1 bs=512 count=2879
3. 运行
VirtualBox运行结果:Bochs运行结果:
4. 参考
于渊《自己动手写操作系统》关于.code16指令:http://web.mit.edu/gnu/doc/html/as_18.html#SEC209
相关文章推荐
- 《Orange's 一个操作系统的实现》学习笔记--一个简单的引导扇区
- 操作系统:使用AT&T实现引导扇区
- 操作系统:实现引导扇区
- 从零开始搭建环境编写操作系统 AT&T GCC (八)使用键盘和滚轮鼠标
- 读书笔记:Orange's 一个操作系统的实现(1) - 实验环境搭建和引导扇区的编写
- 操作系统:实现引导扇区
- 利用bochs完成《orange's一个人的操作系统》引导扇区的实验
- 自制操作系统:引导扇区的实现
- ViewFlipper + GestureDetector 实现App首次使用显示引导页
- 使用IKAnalyzer实现中文分词&去除中文停用词
- Android学习笔记十七.使用ContentProvider实现数据共享(四).操作系统(联系人)的ContentProvider
- 一个分解字符串函数strtok 实现(不使用<string.h>)
- ubuntu12.04中使用gnome-classic经典桌面 putty & vnc实现远程登录linux(有图有真相)
- Oracle中使用escape关键字实现like匹配特殊字符,以及&字符的转义
- 【Android UI设计与开发】2.引导界面(二)使用ViewPager实现欢迎引导页面
- Android UI开发第四十三篇——使用Property Animation实现墨迹天气3.0引导界面及动画实现
- 【Android UI设计与开发】第02期:引导界面(二)使用ViewPager实现欢迎引导页面
- C++链表AT&T代码,通过Ubuntu实现生成(Linux内核分析笔记)
- 《Orange's 一个操作系统的实现》学习笔记--保护模式理论初步(一)
- 《Orange's 一个操作系统的实现》学习笔记--保护模式理论初步(二)