File: bootsect.S

package info (click to toggle)
faumachine 20110812-1.2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 54,124 kB
  • sloc: ansic: 189,713; makefile: 3,947; asm: 3,645; perl: 2,991; sh: 1,471; python: 573; xml: 563; lex: 212; vhdl: 204
file content (153 lines) | stat: -rw-r--r-- 1,848 bytes parent folder | download | duplicates (2)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
; $Id: bootsect.S,v 1.2 2009-01-28 16:47:17 potyra Exp $
; 
; Copyright (C) 2004-2009 FAUmachine Team <info@faumachine.org>.
; This program is free software. You can redistribute it and/or modify it
; under the terms of the GNU General Public License, either version 2 of
; the License, or (at your option) any later version. See COPYING.

.code16
.text

.global _start
_start:
	/* Switch to vga mode 3. */
	movb $3, %al
	movb $0x00, %ah
	int $0x10

	/* Get values of all palette registers. */
	movw $0, %cx
loop_palette:
	pushw %cx

	movb %cl, %bl
	movw $0x1007, %ax
	int $0x10

	movb %bh, %al
	call hex

	call space

	popw %cx
	incw %cx
	cmpw $0x10, %cx
	jne loop_palette

	movb $'\n', %al
	movb $0x0e, %ah
	int $0x10
	movb $'\r', %al
	movb $0x0e, %ah
	int $0x10

	/* Get values of all color registers. */
	movw $0, %cx
loop_dac:
	pushw %cx

	movb %cl, %bl
	movw $0x1015, %ax
	int $0x10

	pushw %cx
	pushw %dx

	movb %dh, %al
	call hex

	call space

	popw %dx
	popw %cx

	pushw %cx
	pushw %dx

	movb %ch, %al
	call hex

	call space

	popw %dx
	popw %cx

	pushw %cx
	pushw %dx

	movb %cl, %al
	call hex

	call space

	popw %dx
	popw %cx

	call space

	popw %cx
	inc %cx
	cmpw $64, %cx
	jne loop_dac

	movb $'\n', %al
	movb $0x0e, %ah
	int $0x10
	movb $'\r', %al
	movb $0x0e, %ah
	int $0x10
	movb $'d', %al
	movb $0x0e, %ah
	int $0x10
	movb $'o', %al
	movb $0x0e, %ah
	int $0x10
	movb $'n', %al
	movb $0x0e, %ah
	int $0x10
	movb $'e', %al
	movb $0x0e, %ah
	int $0x10

loop:
	jmp loop

space:
	pushw %ax
	movb $' ', %al
	movb $0x0e, %ah
	int $0x10
	popw %ax
	ret

hex:
	pushw %ax
	shrb $4, %al
	andb $0x0f, %al
	call digit
	popw %ax
	pushw %ax
	andb $0x0f, %al
	call digit
	popw %ax
	ret

digit:
	pushw %ax

	cmpb $10, %al
	jge 1f

	addb $'0', %al
	jmp 2f

1:	addb $'A'-10, %al

2:	movb $0x0e, %ah
	int $0x10

	popw %ax
	ret

.org 510
	.word 0xAA55