Index: kernel/arch/amd64/src/asm.S
===================================================================
--- kernel/arch/amd64/src/asm.S	(revision 8a5a902af34592bce127314cf2fc188c642817f3)
+++ kernel/arch/amd64/src/asm.S	(revision 0ca441cd372e38bab04fe49abcfe22ead9b21afc)
@@ -37,4 +37,6 @@
 .global read_efer_flag
 .global set_efer_flag
+.global memset
+.global memcpy
 .global memcpy_from_uspace
 .global memcpy_to_uspace
@@ -43,10 +45,47 @@
 .global early_putchar
 
+#define MEMSET_DST   %rdi
+#define MEMSET_VAL   %rsi
+#define MEMSET_SIZE  %rdx
+
 #define MEMCPY_DST   %rdi
 #define MEMCPY_SRC   %rsi
 #define MEMCPY_SIZE  %rdx
 
-/**
- * Copy memory from/to userspace.
+/* Fill memory with byte pattern
+ *
+ * This is a conventional memset().
+ *
+ * @param MEMSET_DST  Destination address.
+ * @param MEMSET_VAL  Value to fill.
+ * @param MEMSET_SIZE Size.
+ *
+ * @return MEMSET_DST.
+ *
+ */
+memset:
+	movq MEMSET_DST, %r8    /* save %rdi */
+	
+	/* Create byte pattern */
+	movzbl %sil, %esi       /* MEMSET_VAL */
+	movabs $0x0101010101010101, %rax
+	imulq %rsi, %rax
+	
+	movq MEMSET_SIZE, %rcx
+	shrq $3, %rcx           /* size / 8 */
+	
+	rep stosq               /* store as much as possible word by word */
+	
+	movq MEMSET_SIZE, %rcx
+	andq $7, %rcx           /* size % 8 */
+	jz 0f
+	
+	rep stosb               /* store the rest byte by byte */
+	
+	0:
+		movq %r8, %rax
+		ret                 /* return MEMCPY_SRC, success */
+
+/** Copy memory from/to userspace.
  *
  * This is almost conventional memcpy().
@@ -63,4 +102,5 @@
  *
  */
+memcpy:
 memcpy_from_uspace:
 memcpy_to_uspace:
Index: uspace/lib/c/arch/amd64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/amd64/Makefile.inc	(revision 8a5a902af34592bce127314cf2fc188c642817f3)
+++ uspace/lib/c/arch/amd64/Makefile.inc	(revision 0ca441cd372e38bab04fe49abcfe22ead9b21afc)
@@ -28,4 +28,5 @@
 
 ARCH_SOURCES = \
+	arch/$(UARCH)/src/asm.S \
 	arch/$(UARCH)/src/entry.s \
 	arch/$(UARCH)/src/entryjmp.s \
Index: uspace/lib/c/arch/amd64/src/asm.S
===================================================================
--- uspace/lib/c/arch/amd64/src/asm.S	(revision 0ca441cd372e38bab04fe49abcfe22ead9b21afc)
+++ uspace/lib/c/arch/amd64/src/asm.S	(revision 0ca441cd372e38bab04fe49abcfe22ead9b21afc)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+.text
+.global memset
+.global memcpy
+
+#define MEMSET_DST   %rdi
+#define MEMSET_VAL   %rsi
+#define MEMSET_SIZE  %rdx
+
+#define MEMCPY_DST   %rdi
+#define MEMCPY_SRC   %rsi
+#define MEMCPY_SIZE  %rdx
+
+/* Fill memory with byte pattern
+ *
+ * This is a conventional memset().
+ *
+ * @param MEMSET_DST  Destination address.
+ * @param MEMSET_VAL  Value to fill.
+ * @param MEMSET_SIZE Size.
+ *
+ * @return MEMSET_DST.
+ *
+ */
+memset:
+	movq MEMSET_DST, %r8    /* save %rdi */
+	
+	/* Create byte pattern */
+	movzbl %sil, %esi       /* MEMSET_VAL */
+	movabs $0x0101010101010101, %rax
+	imulq %rsi, %rax
+	
+	movq MEMSET_SIZE, %rcx
+	shrq $3, %rcx           /* size / 8 */
+	
+	rep stosq               /* store as much as possible word by word */
+	
+	movq MEMSET_SIZE, %rcx
+	andq $7, %rcx           /* size % 8 */
+	jz 0f
+	
+	rep stosb               /* store the rest byte by byte */
+	
+	0:
+		movq %r8, %rax
+		ret                 /* return MEMCPY_SRC, success */
+
+/** Copy memory from/to userspace.
+ *
+ * This is a conventional memcpy().
+ *
+ * @param MEMCPY_DST  Destination address.
+ * @param MEMCPY_SRC  Source address.
+ * @param MEMCPY_SIZE Number of bytes to copy.
+ *
+ * @retrun MEMCPY_DST on success, 0 on failure.
+ *
+ */
+memcpy:
+	movq MEMCPY_DST, %rax
+	
+	movq MEMCPY_SIZE, %rcx
+	shrq $3, %rcx           /* size / 8 */
+	
+	rep movsq               /* copy as much as possible word by word */
+	
+	movq MEMCPY_SIZE, %rcx
+	andq $7, %rcx           /* size % 8 */
+	jz 0f
+	
+	rep movsb               /* copy the rest byte by byte */
+	
+	0:
+		ret                 /* return MEMCPY_SRC, success */
