FS#11335 by me: make ARM assembly functions thumb-friendly
[kugel-rb.git] / firmware / target / arm / olympus / mrobe-100 / lcd-as-mr100.S
blob09778014c1bd10b683fde72ce6155f53cac1bb49
1 /***************************************************************************
2  *             __________               __   ___.
3  *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4  *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5  *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6  *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7  *                     \/            \/     \/    \/            \/
8  * $Id$
9  *
10  * Copyright (C) 2008 by Jens Arnold
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18  * KIND, either express or implied.
19  *
20  ****************************************************************************/
22 #include "config.h"
23 #include "cpu.h"
25     .text
26     .align      2
29     .global     lcd_write_data
30     .type       lcd_write_data,%function
32 lcd_write_data:
33     ldr     r12, =LCD1_BASE
35 .loop:
36     ldrb    r2, [r0], #1
38     ldr     r3, [r12]
39     tst     r3, #LCD1_BUSY_MASK
40     bne     1b
41     str     r2, [r12, #0x10]
43     subs    r1, r1, #1
44     bne     .loop
46     bx      lr
47     .size   lcd_write_data,.-lcd_write_data
50     .global     lcd_grey_data
51     .type       lcd_grey_data,%function
53 /* A high performance function to write grey phase data to the display,
54  * one or multiple pixels.
55  *
56  * Arguments:
57  *   r0 - pixel value data address
58  *   r1 - pixel phase data address
59  *   r2 - pixel block count
60  *
61  * Register usage:
62  *   r3/r4 - current block of phases
63  *   r5/r6 - current block of values
64  *   r7  - lcd data accumulator
65  *   r12 - phase signs mask
66  *   lr  - lcd bridge address
67  */
69 lcd_grey_data:
70     stmfd   sp!, {r4-r7, lr}
71     mov     r12, #0x80
72     orr     r12, r12, r12, lsl #8
73     orr     r12, r12, r12, lsl #16
74     ldr     lr, =LCD1_BASE
76 .greyloop:
77     ldmia   r1, {r3-r4}
78     
79     and     r5, r12, r3         /* r5 = 3.......2.......1.......0....... */
80     and     r6, r12, r4         /* r6 = 7.......6.......5.......4....... */
81     orr     r5, r5, r6, lsr #4  /* r5 = 3...7...2...6...1...5...0...4... */
82     orr     r5, r5, r5, lsr #9  /* r5 = 3...7...23..67..12..56..01..45.. */
83     orr     r5, r5, r5, lsr #9  /* r5 = 3...7...23..67..123.567.012.456. */
84     orr     r5, r5, r5, lsr #9  /* r5 = 3...7...23..67..123.567.01234567 */
85     
86     ldmia   r0!, {r6-r7}
87     bic     r3, r3, r12
88     add     r3, r3, r6
89     bic     r4, r4, r12
90     add     r4, r4, r7
91     stmia   r1!, {r3-r4}
94     ldr     r6, [lr]
95     tst     r6, #LCD1_BUSY_MASK
96     bne     1b
97     str     r5, [lr, #0x10]
99     subs    r2, r2, #1
100     bne     .greyloop
102     ldmpc   regs=r4-r7
103     .size   lcd_grey_data,.-lcd_grey_data