-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipl.asm
90 lines (86 loc) · 1.3 KB
/
ipl.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
CYLS EQU 10
org 07c00h ; 告诉编译器程序加载到7c00处
JMP entry
DB 0x90
DB "HARIBOTE"
DW 512
DB 1
DW 1
DB 2
DW 224
DW 2880
DB 0xf0
DW 9
DW 18
DW 2
DD 0
DD 2880
DB 0,0,0x29
DD 0xffffffff
DB "HARIBOTEOS "
DB "FAT12 "
TIMES 18 db 0
entry:
MOV AX,0
MOV SS,AX
MOV SP,07c00h
MOV DS,AX
MOV AX,00820h
MOV ES,AX
MOV CH,0 ; 柱面0
MOV DH,0 ; 磁头0
MOV CL,2 ; 扇区2
readloop:
MOV SI, 0
retry:
MOV AH,0x02 ; 读入磁盘
MOV AL, 1 ; 1个扇区
MOV BX, 0
MOV DL,0x00 ; A驱动器
INT 0x13 ; 调用
JNC next
ADD SI, 1
CMP SI, 5
JAE error
MOV AH, 0x00
MOV DL, 0x00
INT 0x13 ;重置驱动器
JMP retry
next:
MOV AX, ES
ADD AX, 0x20
MOV ES, AX
ADD CL, 1
CMP CL, 18
JBE readloop
MOV CL, 1
ADD DH, 1
CMP DH, 2
JB readloop
MOV DH, 0
ADD CH, 1
CMP CH, CYLS
JB readloop
MOV [0x0ff0], CH
JMP 0c400h
fin:
HLT
JMP fin
error:
MOV SI,msg
putloop:
MOV AL,[SI]
ADD SI,1
CMP AL,0
JE fin
MOV AH,0x0e
MOV BX,15
INT 0x10
JMP putloop
msg:
DB 0x0a, 0x0a
DB "load error"
DB 0x0a
DB 0
TIMES 510-($-$$) db 0 ; 填充剩下的空间,使生成的二进制代码恰好为512字节
DB 0x55, 0xaa