summaryrefslogtreecommitdiff
path: root/libc/string/nds32/memset.S
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2016-04-21 01:25:29 +0200
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-06-30 03:24:42 +0200
commitee92c0fe5c1b9d59508273916e2c9a75b68dbc13 (patch)
tree65a22258b12f84325910fc2ad47e2b02696ef593 /libc/string/nds32/memset.S
parentdd46699e46decb7273f44dc2cbf307f096dc39e8 (diff)
nds32: add support for new architecture
Add support for Andes Technology NDS32 architecture. See here http://www.andestech.com/en/index/index.htm for more informaton. Verification of the port from an older uClibc port was done on a sponsored AG101p board. The testsuite only has 5 errors, three are related to an existing bug in dlclose() with LT.old, also happening on cris32 and m68k. Failures to fallocate/posix_fallocate are unresolved. Thanks to Andes Technology sponsoring the hardware and being very helpful while doing the uClibc-ng porting. Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
Diffstat (limited to 'libc/string/nds32/memset.S')
-rw-r--r--libc/string/nds32/memset.S66
1 files changed, 66 insertions, 0 deletions
diff --git a/libc/string/nds32/memset.S b/libc/string/nds32/memset.S
new file mode 100644
index 000000000..edd15a410
--- /dev/null
+++ b/libc/string/nds32/memset.S
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2016 Andes Technology, Inc.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/* Copyright (C) 1998, 2003 Free Software Foundation, Inc.
+ * Contributed by Philip Blundell <philb@gnu.org>
+ *
+ * The GNU C Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * The GNU C Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the GNU C Library; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#include <features.h>
+#include <sysdep.h>
+!==========================================================
+! void *memset(void *dst, int val, int len);
+!
+! dst: $r0
+! val: $r1
+! len: $r2
+! ret: $r0 - pointer to the memory area dst.
+!==========================================================
+.weak memset
+ENTRY(memset)
+ move $r5, $r0 ! Return value
+ beqz $r2, .Lend_memset ! Exit when len = 0
+ srli $r3, $r2, 2 ! r3 is how many words to copy
+ andi $r2, $r2, 3 ! How many bytes are less than a word
+ beqz $r3, .Lbyte_set ! When n is less than a word
+
+ ! set r1 from to abababab
+ andi $r1, $r1, 0x00ff ! r1 = 000000ab
+ slli $r4, $r1, 8 ! r4 = 0000ab00
+ or $r1, $r1, $r4 ! r1 = 0000abab
+ slli $r4, $r1, 16 ! r4 = abab0000
+ or $r1, $r1, $r4 ! r1 = abababab
+
+.Lword_set:
+ addi $r3, $r3, -1 ! How many words left to copy
+ smw.bim $r1, [$r5], $r1 ! Copy the word to det
+ bnez $r3, .Lword_set ! Still words to set, continue looping
+ beqz $r2, .Lend_memset ! No left byte to set
+
+.Lbyte_set:
+ ! Less than 4 bytes left to set
+ addi $r2, $r2, -1 ! Decrease len by 1
+ sbi.p $r1, [$r5], 1 ! Set data of the next byte to r1
+ bnez $r2, .Lbyte_set ! Still bytes left to set
+
+.Lend_memset:
+ ret
+
+END(memset)
+libc_hidden_def(memset)