Blame view

boot.asm 1.94 KB
Imanol-Mikel Barba Sabariego authored
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
Imanol-Mikel Barba Sabariego authored
11
;LIGHT_GREEN	0xA
Imanol-Mikel Barba Sabariego authored
12
13
;LIGHT_CYAN		0xB
;LIGHT_RED		0xC
Imanol-Mikel Barba Sabariego authored
14
15
;LIGHT_MAGENTA  0xD
;LIGHT_BROWN	0xE
Imanol-Mikel Barba Sabariego authored
16
17
18
19
20
;WHITE			0xF

[BITS 16]
[org 0x7C00]
Imanol-Mikel Barba Sabariego authored
21
JMP	short Start
Imanol-Mikel Barba Sabariego authored
22
Imanol-Mikel Barba Sabariego authored
23
str: 	db 'THE GAME ',0x00
Imanol-Mikel Barba Sabariego authored
24
25

clear_screen:
Imanol-Mikel Barba Sabariego authored
26
	PUSH	ax
Imanol-Mikel Barba Sabariego authored
27
	MOV     al, 03h ; Setting the graphical mode 80x25(text)
Imanol-Mikel Barba Sabariego authored
28
29
    MOV     ah, 00h ; Code of the function of changing video mode
    INT		10h	; Call interruption
Imanol-Mikel Barba Sabariego authored
30
31
32
    MOV		cl, 0x06
    MOV		ah, 0x01
    INT 	10h
Imanol-Mikel Barba Sabariego authored
33
    POP		ax
Imanol-Mikel Barba Sabariego authored
34
35
36
	RETN

print_string:   ; Expects null terminated message in si
Imanol-Mikel Barba Sabariego authored
37
	PUSH	ax
Imanol-Mikel Barba Sabariego authored
38
39
	for_print_string_0:
		MOV 	al,[si]
Imanol-Mikel Barba Sabariego authored
40
41
		OR 		al,al
		JZ  	end_for_print_string_0
Imanol-Mikel Barba Sabariego authored
42
43
44
		INC 	si
		CALL 	print_char
		JMP 	for_print_string_0
Imanol-Mikel Barba Sabariego authored
45
46
	end_for_print_string_0:
	POP		ax
Imanol-Mikel Barba Sabariego authored
47
48
49
50
	RETN

print_sector:
	PUSH	ebp
Imanol-Mikel Barba Sabariego authored
51
	MOV		ebp, esp
Imanol-Mikel Barba Sabariego authored
52
53
54
55
	PUSH	ax
	PUSH	bx
	PUSH	cx
	PUSH	dx
Imanol-Mikel Barba Sabariego authored
56
57
	MOV 	al, [6 + ebp] ; num
	MOV		cl, [8 + ebp]  ; offset
Imanol-Mikel Barba Sabariego authored
58
	MOV     ah, 2
Imanol-Mikel Barba Sabariego authored
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
    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
Imanol-Mikel Barba Sabariego authored
83
84
85
86
87
88
89
90
91
	RETN

print_char:
	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
Imanol-Mikel Barba Sabariego authored
92
93
	POP		bx
	POP		ax
Imanol-Mikel Barba Sabariego authored
94
95
	RETN
Imanol-Mikel Barba Sabariego authored
96
97
98
99
100
101
102
103
104
105
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)
Imanol-Mikel Barba Sabariego authored
106
ADD		esp, 4
Imanol-Mikel Barba Sabariego authored
107
108
109
110
111
112
113
114
for_start_0:
	MOV 	si,str
	CALL 	print_string
	;JMP 	for_start_0
	JMP	$


TIMES 	510 - ($ - $$) db 0
Imanol-Mikel Barba Sabariego authored
115
116
117
118
DW 		0xAA55