Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: byteswap.s | |
5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | * | |
8 | * The above named program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * The above named program is distributed in the hope that it will be | |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public | |
18 | * License along with this work; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | * | |
21 | * ========== Copyright Header End ============================================ | |
22 | */ | |
23 | #if defined(ARCH_AMD64) | |
24 | ||
25 | .text | |
26 | ||
27 | /*============================================================================*\ | |
28 | * uint16_t byteswap16( uint16_t v ) | |
29 | \*============================================================================*/ | |
30 | .align 16 | |
31 | .globl byteswap16 | |
32 | .type byteswap16, @function | |
33 | byteswap16: | |
34 | movw %di,%ax | |
35 | xchgb %ah,%al | |
36 | ret | |
37 | .size byteswap16, [.-byteswap16] | |
38 | ||
39 | /*============================================================================*\ | |
40 | * uint32_t byteswap32( uint32_t v ) | |
41 | \*============================================================================*/ | |
42 | .align 16 | |
43 | .globl byteswap32 | |
44 | ||
45 | .type byteswap32, @function | |
46 | byteswap32: | |
47 | movl %edi,%eax | |
48 | bswapl %eax | |
49 | ret | |
50 | .size byteswap32, [.-byteswap32] | |
51 | ||
52 | /*============================================================================*\ | |
53 | * uint64_t byteswap64( uint64_t v ) | |
54 | \*============================================================================*/ | |
55 | .align 16 | |
56 | .globl byteswap64 | |
57 | .type byteswap64, @function | |
58 | byteswap64: | |
59 | movq %rdi,%rax | |
60 | bswapq %rax | |
61 | ret | |
62 | .size byteswap64, [.-byteswap64] | |
63 | ||
64 | #endif |