1/*
2 *  linux/arch/arm/lib/ll_char_wr.S
3 *
4 *  Copyright (C) 1995, 1996 Russell King.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 *  Speedups & 1bpp code (C) 1996 Philip Blundell & Russell King.
11 *
12 *  10-04-96	RMK	Various cleanups & reduced register usage.
13 *  08-04-98	RMK	Shifts re-ordered
14 */
15
16@ Regs: [] = corruptible
17@       {} = used
18@       () = do not use
19
20#include <linux/linkage.h>
21#include <asm/assembler.h>
22	.text
23
24LC0:	.word	LC0
25	.word	bytes_per_char_h
26	.word	video_size_row
27	.word	acorndata_8x8
28	.word	con_charconvtable
29
30/*
31 * r0 = ptr
32 * r1 = char
33 * r2 = white
34 */
35ENTRY(ll_write_char)
36	stmfd	sp!, {r4 - r7, lr}
37@
38@ Smashable regs: {r0 - r3}, [r4 - r7], (r8 - fp), [ip], (sp), [lr], (pc)
39@
40	/*
41	 * calculate offset into character table
42	 */
43	mov	r1, r1, lsl #3
44	/*
45	 * calculate offset required for each row.
46	 */
47	adr	ip, LC0
48	ldmia	ip, {r3, r4, r5, r6, lr}
49	sub	ip, ip, r3
50	add	r6, r6, ip
51	add	lr, lr, ip
52	ldr	r4, [r4, ip]
53	ldr	r5, [r5, ip]
54	/*
55	 * Go to resolution-dependent routine...
56	 */
57	cmp	r4, #4
58	blt	Lrow1bpp
59	add	r0, r0, r5, lsl #3		@ Move to bottom of character
60	orr	r1, r1, #7
61	ldrb	r7, [r6, r1]
62	teq	r4, #8
63	beq	Lrow8bpplp
64@
65@ Smashable regs: {r0 - r3}, [r4], {r5 - r7}, (r8 - fp), [ip], (sp), {lr}, (pc)
66@
67Lrow4bpplp:
68	ldr	r7, [lr, r7, lsl #2]
69	mul	r7, r2, r7
70	sub	r1, r1, #1			@ avoid using r7 directly after
71	str	r7, [r0, -r5]!
72	ldrb	r7, [r6, r1]
73	ldr	r7, [lr, r7, lsl #2]
74	mul	r7, r2, r7
75	tst	r1, #7				@ avoid using r7 directly after
76	str	r7, [r0, -r5]!
77	subne	r1, r1, #1
78	ldrneb	r7, [r6, r1]
79	bne	Lrow4bpplp
80	ldmfd	sp!, {r4 - r7, pc}
81
82@
83@ Smashable regs: {r0 - r3}, [r4], {r5 - r7}, (r8 - fp), [ip], (sp), {lr}, (pc)
84@
85Lrow8bpplp:
86	mov	ip, r7, lsr #4
87	ldr	ip, [lr, ip, lsl #2]
88	mul	r4, r2, ip
89	and	ip, r7, #15			@ avoid r4
90	ldr	ip, [lr, ip, lsl #2]		@ avoid r4
91	mul	ip, r2, ip			@ avoid r4
92	sub	r1, r1, #1			@ avoid ip
93	sub	r0, r0, r5			@ avoid ip
94	stmia	r0, {r4, ip}
95	ldrb	r7, [r6, r1]
96	mov	ip, r7, lsr #4
97	ldr	ip, [lr, ip, lsl #2]
98	mul	r4, r2, ip
99	and	ip, r7, #15			@ avoid r4
100	ldr	ip, [lr, ip, lsl #2]		@ avoid r4
101	mul	ip, r2, ip			@ avoid r4
102	tst	r1, #7				@ avoid ip
103	sub	r0, r0, r5			@ avoid ip
104	stmia	r0, {r4, ip}
105	subne	r1, r1, #1
106	ldrneb	r7, [r6, r1]
107	bne	Lrow8bpplp
108	ldmfd	sp!, {r4 - r7, pc}
109
110@
111@ Smashable regs: {r0 - r3}, [r4], {r5, r6}, [r7], (r8 - fp), [ip], (sp), [lr], (pc)
112@
113Lrow1bpp:
114	add	r6, r6, r1
115	ldmia	r6, {r4, r7}
116	strb	r4, [r0], r5
117	mov	r4, r4, lsr #8
118	strb	r4, [r0], r5
119	mov	r4, r4, lsr #8
120	strb	r4, [r0], r5
121	mov	r4, r4, lsr #8
122	strb	r4, [r0], r5
123	strb	r7, [r0], r5
124	mov	r7, r7, lsr #8
125	strb	r7, [r0], r5
126	mov	r7, r7, lsr #8
127	strb	r7, [r0], r5
128	mov	r7, r7, lsr #8
129	strb	r7, [r0], r5
130	ldmfd	sp!, {r4 - r7, pc}
131
132	.bss
133ENTRY(con_charconvtable)
134	.space	1024
135