add a toy bootloader in real mode of x86

This commit is contained in:
yuchen 2015-03-13 21:59:52 +08:00
parent 6770c2a473
commit de888683e8
3 changed files with 47 additions and 0 deletions

View 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

View 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 /* 00*/
int $0x10 /* BIOSint0x100x13 */
ret
.org 0x1fe, 0x90
.word 0xaa55

View 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
```