Browse Source

add a toy bootloader in real mode of x86

main
yuchen 9 years ago
parent
commit
de888683e8
3 changed files with 47 additions and 0 deletions
  1. +9
    -0
      related_info/lab1/toybootloader/Makefile
  2. +30
    -0
      related_info/lab1/toybootloader/toy.S
  3. +8
    -0
      related_info/lab1/toybootloader/toy.md

+ 9
- 0
related_info/lab1/toybootloader/Makefile 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

+ 30
- 0
related_info/lab1/toybootloader/toy.S 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 /* BIOS提供的int服务0x10的0x13功能 */
ret
.org 0x1fe, 0x90
.word 0xaa55

+ 8
- 0
related_info/lab1/toybootloader/toy.md 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
```

Loading…
Cancel
Save