-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.asm
129 lines (126 loc) · 2.18 KB
/
loader.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
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
; MyOS: loader
; author: vyaslav
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
org 7c00h
;############################
DEF_SET equ 1h
DEF_RUN equ 0h
DEF_RSAVE equ 2h
DEF_RREST equ 3h
DEF_RESET equ 4h
;############################
;+BIOS_putc
; +DEF_RUN
; -I: al - Char
macro BIOS_putc def {
if def = DEF_SET
mov ah, 09h
mov cx, 1
mov bh, 0
mov bl, 07h
else if def = DEF_RESET
mov ah, 09h
else if def = DEF_RSAVE
push ax bx cx
else if def = DEF_RREST
pop cx bx ax
else if def = DEF_RUN
int 10h
end if
}
;############################
;+BIOS_move_cur
; +DEF_RUN
; -I: dh - cursor row
; -I: dl - cursor col
macro BIOS_move_cur def {
if def = DEF_SET
mov ah, 02h
mov bh, 00h
else if def = DEF_RESET
mov ah, 02h
else if def = DEF_RSAVE
push ax bx
else if def = DEF_RREST
pop bx ax
else if def = DEF_RUN
int 10h
end if
}
;############################
;+C_Print_String
; -I: string - String to output in CS
macro C_Print_String string {
push si dx
BIOS_putc DEF_RSAVE
mov si, string
mov dh, 0
mov dl, byte[cur]
lods byte [cs:si]
;push $+4
;cmp al, 0
;jne iP_PRINTS
;pop dx
call iP_PRINTS
BIOS_putc DEF_RREST
pop dx si
}
;############################
; MAIN
;############################
C_Print_String msg_welcome
;mov dx, 4
mov dh, 0
mov dl, byte[cur]
mov si, -1
start:
;############################
; MAIN LOOP
;############################
mov cx, 3
neg si
add dx, si
cmp si, 1
jne set_dot
mov al, '.'
;skip next
jmp ILOOP
set_dot: mov al, ' '
ILOOP:
push cx
call P_MOVE_CUR
add dx, si
mov byte[cur], dl
call P_PUTC
pop cx
loop ILOOP
jmp start
;############################
cur db 0
msg_welcome db 'MyOS', 0
P_PUTC:
BIOS_putc DEF_SET
BIOS_putc DEF_RUN
ret
P_MOVE_CUR:
BIOS_move_cur DEF_SET
BIOS_move_cur DEF_RUN
ret
iP_PRINTS:
;put char
call P_PUTC
;move curso
inc dl
mov byte[cur], dl
call P_MOVE_CUR
lods byte [cs:si]
cmp al, 0
jne iP_PRINTS
ret
;############################
spam_buffer:
spam db (7dfeh - $) dup (0)
db 55h, 0aah