2 * File: arch/blackfin/lib/memset.S
9 * Rev: $Id: memset.S 2769 2007-02-19 16:45:53Z hennerich $
12 * Copyright 2004-2006 Analog Devices Inc.
14 * Bugs: Enter bugs at http://blackfin.uclinux.org/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see the file COPYING, or write
28 * to the Free Software Foundation, Inc.,
29 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
36 * C Library function MEMSET
37 * R0 = address (leave unchanged to form result)
40 * Favours word aligned data.
45 P0 = R0 ; /* P0 = address */
46 P2 = R2 ; /* P2 = count */
47 R3 = R0 + R2; /* end */
49 IF CC JUMP .Ltoo_small;
50 R1 = R1.B (Z); /* R1 = fill char */
52 R2 = R0 & R2; /* addr bottom two bits */
53 CC = R2 == 0; /* AZ set if zero. */
54 IF !CC JUMP .Lforce_align ; /* Jump if addr not aligned. */
57 P1 = P2 >> 2; /* count = n/4 */
58 R2 = R1 << 8; /* create quad filler */
59 R2.L = R2.L + R1.L(NS);
60 R2.H = R2.L + R1.H(NS);
63 LSETUP (.Lquad_loop , .Lquad_loop) LC0=P1;
68 IF !CC JUMP .Lbytes_left;
72 R2 = R3; /* end point */
73 R3 = P0; /* current position */
74 R2 = R2 - R3; /* bytes left */
78 CC = P2 == 0; /* Check zero count */
79 IF CC JUMP .Lfinished; /* Unusual */
82 LSETUP (.Lbyte_loop , .Lbyte_loop) LC0=P2;
90 CC = BITTST (R0, 0); /* odd byte */
94 R0 = P0; /* Recover return address */
98 CC = R2 <= 2; /* 2 bytes */
99 P2 -= P1; /* reduce count */
100 IF !CC JUMP .Laligned;