|
1
2
3
4
5
6
7
8
9
10
|
;BLACK 0x0
;BLUE 0x1
;GREEN 0x2
;CYAN 0x3
;RED 0x4
;MAGENTA 0x5
;BROWN 0x6
;GREY 0x7
;DARK_GREY 0x8
;LIGHT_BLUE 0x9
|
|
11
|
;LIGHT_GREEN 0xA
|
|
12
13
|
;LIGHT_CYAN 0xB
;LIGHT_RED 0xC
|
|
14
15
|
;LIGHT_MAGENTA 0xD
;LIGHT_BROWN 0xE
|
|
16
17
18
19
20
|
;WHITE 0xF
[BITS 16]
[org 0x7C00]
|
|
21
|
JMP Start
|
|
22
23
|
clear_screen:
|
|
24
|
PUSH ax
|
|
25
|
MOV al, 03h ; Setting the graphical mode 80x25(text)
|
|
26
27
|
MOV ah, 00h ; Code of the function of changing video mode
INT 10h ; Call interruption
|
|
28
29
30
|
MOV cl, 0x06
MOV ah, 0x01
INT 10h
|
|
31
|
POP ax
|
|
32
33
34
|
RETN
print_string: ; Expects null terminated message in si
|
|
35
|
PUSH ax
|
|
36
37
|
for_print_string_0:
MOV al,[si]
|
|
38
39
|
OR al,al
JZ end_for_print_string_0
|
|
40
41
42
|
INC si
CALL print_char
JMP for_print_string_0
|
|
43
44
|
end_for_print_string_0:
POP ax
|
|
45
46
47
48
|
RETN
print_sector:
PUSH ebp
|
|
49
|
MOV ebp, esp
|
|
50
51
52
53
|
PUSH ax
PUSH bx
PUSH cx
PUSH dx
|
|
54
55
|
MOV al, [8 + ebp] ; num
MOV cl, [6 + ebp] ; offset
|
|
56
|
MOV ah, 2
|
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
XOR ch, ch
XOR dx,dx
INT 0x13
MOV di, 512
XOR ah, ah
IMUL di, ax
XOR si, si
for_print_sector_0:
CMP si, di
JZ end_for_print_sector_0
MOV al,[es:si]
OR al, al
JZ end_print_char_0
CALL print_char
end_print_char_0:
INC si
JMP for_print_sector_0
end_for_print_sector_0:
POP dx
POP cx
POP bx
POP ax
MOV esp, ebp
POP ebp
|
|
81
82
|
RETN
|
|
83
|
print_char:
|
|
84
85
86
87
88
89
|
PUSH ax
PUSH bx
MOV ah,0x0E ; Specifies that we want to write a character to the screen
MOV bl,0x02 ; Specifies output text color. Not required, but useful to know
MOV bh,0x00 ; Page number. Leave this alone.
INT 0x10 ; Signal video interrupt to BIOS
|
|
90
91
|
POP bx
POP ax
|
|
92
93
|
RETN
|
|
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
execute_sector:
PUSH ebp
MOV ebp, esp
PUSH ax
PUSH bx
PUSH cx
PUSH dx
MOV ax, [10 + ebp] ; base address
MOV es, ax
MOV al, [8 + ebp] ; num
MOV cl, [6 + ebp] ; offset
MOV ah, 2 ; Function read
XOR ch, ch ; cylinder
XOR dx,dx ; Head and drive
INT 0x13
XOR si, si
PUSH es
PUSH bx
RETF
|
|
115
116
117
118
119
120
121
122
123
124
|
Start:
XOR ax, ax
MOV ds, ax
MOV ax, 0x1000
MOV es, ax
XOR bx, bx
CALL clear_screen
PUSH 2 ; num
PUSH 2 ; offset
CALL print_sector ; (offset, num)
|
|
125
|
ADD esp, 4
|
|
126
127
128
129
130
131
132
|
MOV si,str
CALL print_string
PUSH 0x800; Base address, offset is 0
PUSH 1 ; num
PUSH 4 ; offset
XOR bx, bx;
CALL execute_sector
|
|
133
|
|
|
134
|
str: db 'THE GAME',0x0A,0x0D,0x00
|
|
135
136
|
TIMES 510 - ($ - $$) db 0
|
|
137
138
139
140
|
DW 0xAA55
|