美文网首页
引导程序之显示单字符

引导程序之显示单字符

作者: louyang | 来源:发表于2020-05-28 16:47 被阅读0次

Windows上安装VMWare Player,创建两个虚拟机,一个CentOS用于编写汇编代码,另一个用于测试引导程序(boot-loader)。

image.png
1 在CentOS里

准备 boot.s:

.global init
init:
  mov $0x0e, %ah
  mov $0x41, %al
  int $0x10
  jmp .
.=510
.byte 0x55
.byte 0xaa
$ as -o boot.o boot.s
$ ld -o boot.bin --oformat binary -e init boot.o

boot.bin拷贝到windows的某一个目录中。

2 在裸机中

在裸机的设置中,把软盘指向boot.bin

image.png

开机后:

image.png

另外,如果把init换成_start, 链接命令还能减少一个参数。

.global _start
_start:
  mov $0x0e, %ah
  mov $0x41, %al
  int $0x10 
  jmp .
.=510
.byte 0x55
.byte 0xaa
as -o boot.o boot.s
ld -o boot.bin --oformat binary -o boot.bin boot.o
参考

https://medium.com/@g33konaut/writing-an-x86-hello-world-boot-loader-with-assembly-3e4c5bdd96cf
https://stackoverflow.com/questions/34268518/creating-a-bootable-iso-image-with-custom-bootloader
https://www.viralpatel.net/taj/tutorial/booting.php
https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax
https://www.diag.uniroma1.it/~pellegrini/didattica/2017/aosv/1.Initial-Boot-Sequence.pdf

相关文章

网友评论

      本文标题:引导程序之显示单字符

      本文链接:https://www.haomeiwen.com/subject/qxqvahtx.html