-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader3.asm
More file actions
executable file
·137 lines (98 loc) · 2.3 KB
/
loader3.asm
File metadata and controls
executable file
·137 lines (98 loc) · 2.3 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#make_boot#
org 7c00h ; loaded at 0000:7c00h
jmp start
; Data section
;----------------------------------
loading db "Loading the kernel ........................................................................................"
loading_end:
ld_completed db 0dh, 0ah, 0dh, 0ah, "Loading Completed. Press any key to jump to the kernel"
ld_completed_e:
macro loading_cmpl_msg
MOV AH, 13H ; string function
MOV al, 1 ; update cursor
inc dh
inc dh
mov dl, 0
mov bp, offset ld_completed
mov cx, ld_completed_e - offset ld_completed
mov bh, 0
mov bl, 0000_1011b
int 10h
endm
; Code section
;-----------------------------------
start:
; set data segment and extra segment
xor ax,ax
push cs
push cs
pop ds
pop es
; initialize the stack
mov ax, 07c0h
mov ss, ax
mov sp, 03feh ; top of the stack.
; set display mode
mov ah, 0h
mov al, 03h
int 10h
; set cursor mode
mov ah, 1h
mov ch, 6 ; starting line
mov cl, 7 ; ending line
int 10h
; print loading message
call loading_msg
loading_cmpl_msg
; wait for keystroke
mov ah, 0h
int 16h
; load the kernel at 0800h:0000
mov ah, 02h ; read sector function
mov al, 10 ;load 10 sector
mov ch, 0 ; cylinder 0
mov cl, 2 ; start at sector 2
mov dh, 0 ; head
mov dl, 0 ; dl not changed
; es:bs points to data buffer
mov bx, 0800h
mov es, bx
mov bx, 0
; read sector
int 13h
; pass control to the kernel
jmp 0800h:0000h ; go to the kernel
; Procedure section
;-----------------------------------------
loading_msg proc
; print loading message
push cx
push si
push ax
mov cx, loading_end - offset loading ; string size
mov si , 0 ; index
mov ah, 0eh ; output function
next:
mov al, loading[si] ; attributed string
int 10h
inc si
;;; wait.........
PUSH CX
PUSH DX
PUSH AX
MOV AH, 86H
MOV CX, 0000H
MOV DX, 0ffe8H
INT 15H
POP AX
POP DX
POP CX
;;; wait
loop next
pop ax
pop si
pop cx
ret
endp ; procedure end
db 510-($-7c00H) dup(0)
DW 0AA55H ; boot signature