File: drawtext.S

package info (click to toggle)
chdrv 1.0.13-0.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,204 kB
  • ctags: 1,069
  • sloc: ansic: 8,972; perl: 412; asm: 234; makefile: 195; sh: 36
file content (177 lines) | stat: -rw-r--r-- 2,334 bytes parent folder | download
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177


#include "vgadef.h"	

/*
	20 %x
	16 %y
	12  %buf
	8  %eip
	4  %ebp
*/

X =	8
Y =	12
BUF=	16
COLOR=  20

.text	
.globl ELF(asm_draw_ctext)
.globl ELF(asm_draw_text)
.comm ELF(graph_mem),4	
.comm ELF(vga1_isunderline),1
.align 4
ELF(asm_draw_text):
	
	# calculate the base address
	pushl	%ebp
	movl	%esp,%ebp
	pushl	%edi
	pushl	%esi
	pushl	%ecx
	
	movl	Y(%ebp),%edi
	leal	0(%edi,%edi,4),%edi
	sall	$4,%edi
	addl	X(%ebp),%edi
	addl	ELF(graph_mem),%edi
	movl	BUF(%ebp),%esi
		
	# setup video graphic registers
	mov	$GRA_I,%dx
	movw	$0x0a05,%ax
	outw	%ax,%dx
	movw	$7,%ax
	outw	%ax,%dx
	mov	$0x03,%ax
	outw	%ax,%dx
	movl	$15,%ecx
	movb	$8,%al
	outb	%al,%dx
	inc	%dx
	mov	COLOR(%ebp),%ebx
	cmpb	$255,ELF(vga1_screenmask)
	jnz	L01
	xchg	%bl,%bh
L01:	movb	(%esi),%al
	outb	%al,%dx
	andb	%bl,(%edi)
	not	%al
	outb	%al,%dx
	andb	%bh,(%edi)	
	addl	$80,%edi
	incl	%esi
	decl	%ecx
	jnz	L01
	movb	$0xff,%al
	outb	%al,%dx
	cmpb	$1,ELF(vga1_isunderline)
	jne	L04
	andb	%bl,(%edi)
	jmp     L05
L04:
	andb    %bh,(%edi)
L05:
	mov	$GRA_I,%dx
	mov	$3,%ax
	outw	%ax,%dx
	mov	$0x0805,%ax
	outw	%ax,%dx
	popl	%ecx
	popl	%esi
	popl	%edi
	movl	%ebp,%esp
	popl	%ebp
	ret
.align 4
ELF(asm_draw_ctext):
	
	# calculate the base address
	pushl	%ebp
	movl	%esp,%ebp
	pushl	%edi
	pushl	%esi
	pushl	%ecx
	
	movl	Y(%ebp),%edi
	leal	0(%edi,%edi,4),%edi
	sall	$4,%edi
	addl	X(%ebp),%edi
	addl	ELF(graph_mem),%edi
	movl	BUF(%ebp),%esi
		
	# setup video graphic registers
	movw	$GRA_I,%dx
	movw	$0x0a05,%ax
	outw	%ax,%dx
	movw	$7,%ax
	outw	%ax,%dx
	movw	$03,%ax
	outw	%ax,%dx
	movl	$15,%ecx
	movb	$8,%al
	outb	%al,%dx
	incw	%dx
	mov	COLOR(%ebp),%ebx
	cmpb	$255,ELF(vga1_screenmask)
	jne	L02
	xchg	%bl,%bh
L02:	movb	(%esi),%al
	outb	%al,%dx
	andb	%bl,(%edi)
	not	%al
	outb	%al,%dx
	andb	%bh,(%edi)
	incl	%esi
	incl	%edi
	movb	(%esi),%al
	outb	%al,%dx
	andb	%bl,(%edi)
	not	%al
	outb	%al,%dx
	andb	%bh,(%edi)
L9:	
	addl	$79,%edi
	incl	%esi
	decl	%ecx
	jne	L02
	movb	$0xff,%al
	outb	%al,%dx
	andb    %bh,(%edi)	
	inc     %edi
	andb    %bh,(%edi)
	dec     %edi
	cmpb	$1,ELF(vga1_isunderline)
	jne	L10
	andb	%bl,(%edi)
	incl	%edi
	andb	%bl,(%edi)
	jmp     L11		
L10:
	andb	%bh,(%edi)
	incl	%edi
	andb	%bh,(%edi)
L11:
	movw	$GRA_I,%dx
	movw	$3,%ax
	outw	%ax,%dx
	movw    $0x0805,%ax
	outw	%ax,%dx
	popl	%ecx
	popl	%esi
	popl	%edi
	movl	%ebp,%esp
	popl	%ebp
	ret