ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / s390 / lib / strncpy64.S
1 /*
2  *  arch/s390/kernel/strncpy.S
3  *    S390 strncpy routine
4  *
5  *  S390 version
6  *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7  *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
8  */
9
10 /*
11  * R2 = address of destination
12  * R3 = address of source string
13  * R4 = max number of bytes to copy
14  */
15         .globl   strncpy
16 strncpy:
17         LGR     1,2            # don't touch address in R2
18         LTR     4,4
19         JZ      strncpy_exit   # 0 bytes -> nothing to do
20         SGR     0,0
21 strncpy_loop:
22         ICM     0,1,0(3)       # ICM sets the cc, IC does not
23         LA      3,1(3)
24         STC     0,0(1)
25         LA      1,1(1)
26         JZ      strncpy_pad    # ICM inserted a 0x00
27         BRCTG   4,strncpy_loop # R4 -= 1, jump to strncpy_loop if > 0
28 strncpy_exit:
29         BR      14
30 strncpy_clear:
31         STC     0,0(1)
32         LA      1,1(1)
33 strncpy_pad:
34         BRCTG   4,strncpy_clear
35         BR      14