coreBugZJ

此 blog 已弃。

引导盘初探

零起点写操作系统,留此纪念

软盘引导,使用BIOS 中断设置显示方式并显示字符串

截图:




源码:
const.inc

 1; vedio
 2MDA_ID : equ 0x07
 3MDA_COL_NUM : equ  80
 4MDA_ROW_NUM : equ  25
 5MDA_BASE : equ  0xB0000
 6MDA_BASE_SEG : equ 0xB000
 7MDA_BASE_OFF : equ 0x0
 8
 9
10


boot.s
 1%include "const.inc"
 2
 3org 0x7C00
 4
 5        mov ax, cs
 6        mov ds, ax
 7        mov es, ax
 8        call initVideo
 9        call dispMsg
10        jmp $
11
12dispMsg : 
13        mov ax, msg
14        mov bp, ax
15        mov al, 0x1
16        mov cx, 0x0A 
17        mov dh, 10
18        mov dl, 32
19        mov bh, 0x0
20        mov bl, 0x0C
21        mov ah, 0x13
22        int 0x10
23        ret
24
25initVideo :
26        mov ah, 0
27        mov al, MDA_ID
28        int 0x10
29        ret
30
31msg : db "Booting"
32times 510-($-$$) db 0
33db 0x55
34db 0xAA
35
36


2011年4月8日修改:

MDA 只有黑白两色,之前代码有误;const.inc 中 video 笔误。。。

boot.s
 1%include "const.inc"
 2
 3org 0x7C00
 4
 5        mov ax, cs
 6        mov ds, ax
 7        mov es, ax
 8        call initVideo
 9        call dispMsg
10        jmp $
11
12dispMsg : 
13        mov ax, msg
14        mov bp, ax
15        mov al, 0x1
16        mov cx, 0x0A 
17        mov dh, 0xA
18        mov dl, 0x20
19        mov bh, 0x0
20        mov bl, 0x0F
21        mov ah, 0x13
22        int 0x10
23        ret
24
25initVideo :
26        mov ah, 0
27        mov al, MDA_ID
28        int 0x10
29        ret
30
31msg : db "Booting"
32times 510-($-$$) db 0
33db 0x55
34db 0xAA
35
36

posted on 2011-04-04 17:02 coreBugZJ 阅读(247) 评论(0)  编辑 收藏 引用 所属分类: AssembleOperatingSystem


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理