add a toy bootloader in real mode of x86
This commit is contained in:
parent
6770c2a473
commit
de888683e8
9
related_info/lab1/toybootloader/Makefile
Normal file
9
related_info/lab1/toybootloader/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
all:toy
|
||||
toy.o: toy.S
|
||||
as -o toy.o toy.S
|
||||
toy: toy.o
|
||||
ld --oformat binary -N -e start -Ttext 0x7c00 -o toy toy.o
|
||||
run: toy
|
||||
qemu-system-i386 -fda toy
|
||||
clean:
|
||||
rm toy.o toy
|
30
related_info/lab1/toybootloader/toy.S
Normal file
30
related_info/lab1/toybootloader/toy.S
Normal file
@ -0,0 +1,30 @@
|
||||
.text
|
||||
.globl start /* 程序从start处开始运行 */
|
||||
.code16
|
||||
start:
|
||||
jmpl $0x0, $code
|
||||
msg:
|
||||
.string "Hello world!"
|
||||
code:
|
||||
mov %cs,%ax
|
||||
mov %ax,%ds
|
||||
mov %ax,%es
|
||||
mov %ax,%ss
|
||||
mov $0x400,%sp
|
||||
call dispstr /* call dispstr函数显示字符串 */
|
||||
|
||||
loop0: /* 无限循环 */
|
||||
jmp loop0
|
||||
|
||||
dispstr:
|
||||
mov $msg ,%ax
|
||||
mov %ax ,%bp /* es:bp = 串地址 */
|
||||
mov $12 ,%cx /* cs = 串长度 */
|
||||
mov $0x1301 ,%ax /* ah=0x13:显示字符串 ,al=0x1:显示输出方式 */
|
||||
mov $0x000c ,%bx /* bh=0 :第0页, bl=0xc :高亮 黑底红字 */
|
||||
mov $0 ,%dl /* 在0行0列显示*/
|
||||
int $0x10 /* 调用BIOS提供的int服务0x10的0x13功能:显示字符串 */
|
||||
ret
|
||||
|
||||
.org 0x1fe, 0x90
|
||||
.word 0xaa55
|
8
related_info/lab1/toybootloader/toy.md
Normal file
8
related_info/lab1/toybootloader/toy.md
Normal file
@ -0,0 +1,8 @@
|
||||
From http://blog.csdn.net/guocaigao/article/details/8476086
|
||||
|
||||
A toy bootloader can display string in real mode of x86.
|
||||
|
||||
Try
|
||||
```
|
||||
make run
|
||||
```
|
Loading…
Reference in New Issue
Block a user