零起點寫操作系統,留此紀念
軟盤引導,使用BIOS 中斷設置顯示方式并顯示字符串
截圖:

源碼:
const.inc
1
; vedio
2
MDA_ID : equ 0x07
3
MDA_COL_NUM : equ 80
4
MDA_ROW_NUM : equ 25
5
MDA_BASE : equ 0xB0000
6
MDA_BASE_SEG : equ 0xB000
7
MDA_BASE_OFF : equ 0x0
8
9
10
boot.s
1
%include "const.inc"
2
3
org 0x7C00
4
5
mov ax, cs
6
mov ds, ax
7
mov es, ax
8
call initVideo
9
call dispMsg
10
jmp $
11
12
dispMsg :
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
25
initVideo :
26
mov ah, 0
27
mov al, MDA_ID
28
int 0x10
29
ret
30
31
msg : db "Booting
"
32
times 510-($-$$) db 0
33
db 0x55
34
db 0xAA
35
36
2011年4月8日修改:
MDA 只有黑白兩色,之前代碼有誤;const.inc 中 video 筆誤。。。
boot.s
1
%include "const.inc"
2
3
org 0x7C00
4
5
mov ax, cs
6
mov ds, ax
7
mov es, ax
8
call initVideo
9
call dispMsg
10
jmp $
11
12
dispMsg :
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
25
initVideo :
26
mov ah, 0
27
mov al, MDA_ID
28
int 0x10
29
ret
30
31
msg : db "Booting
"
32
times 510-($-$$) db 0
33
db 0x55
34
db 0xAA
35
36