4 * Copyright 2004-2007 Analog Devices Inc.
5 * Enter bugs at http://blackfin.uclinux.org/
7 * SPDX-License-Identifier: GPL-2.0+
13 * C Library function MEMSET
14 * R0 = address (leave unchanged to form result)
17 * Favours word aligned data.
21 .type _memset, STT_FUNC;
23 P0 = R0 ; /* P0 = address */
24 P2 = R2 ; /* P2 = count */
25 R3 = R0 + R2; /* end */
27 IF CC JUMP .Ltoo_small;
28 R1 = R1.B (Z); /* R1 = fill char */
30 R2 = R0 & R2; /* addr bottom two bits */
31 CC = R2 == 0; /* AZ set if zero. */
32 IF !CC JUMP .Lforce_align ; /* Jump if addr not aligned. */
35 P1 = P2 >> 2; /* count = n/4 */
36 R2 = R1 << 8; /* create quad filler */
37 R2.L = R2.L + R1.L(NS);
38 R2.H = R2.L + R1.H(NS);
41 LSETUP (.Lquad_loop , .Lquad_loop) LC0=P1;
46 IF !CC JUMP .Lbytes_left;
50 R2 = R3; /* end point */
51 R3 = P0; /* current position */
52 R2 = R2 - R3; /* bytes left */
56 CC = P2 == 0; /* Check zero count */
57 IF CC JUMP .Lfinished; /* Unusual */
60 LSETUP (.Lbyte_loop , .Lbyte_loop) LC0=P2;
68 CC = BITTST (R0, 0); /* odd byte */
72 R0 = P0; /* Recover return address */
76 CC = R2 <= 2; /* 2 bytes */
77 P2 -= P1; /* reduce count */
78 IF !CC JUMP .Laligned;
83 .size _memset, .-_memset