libcdio  0.83
bytesex_asm.h
Go to the documentation of this file.
1 /*
2  $Id: bytesex_asm.h,v 1.3 2008/03/25 15:59:08 karl Exp $
3 
4  Copyright (C) 2008 Rocky Bernstein <rocky@gnu.org>
5  2001, 2004, 2005 Herbert Valerio Riedel <hvr@gnu.org>
6  2001 Sven Ottemann <ac-logic@freenet.de>
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
29 #ifndef __CDIO_BYTESEX_ASM_H__
30 #define __CDIO_BYTESEX_ASM_H__
31 #if !defined(DISABLE_ASM_OPTIMIZE)
32 
33 #include <cdio/types.h>
34 
35 #if defined(__powerpc__) && defined(__GNUC__)
36 
37 inline static
38 uint32_t uint32_swap_le_be_asm(const uint32_t a)
39 {
40  uint32_t b;
41 
42  __asm__ ("lwbrx %0,0,%1"
43  :"=r"(b)
44  :"r"(&a), "m"(a));
45 
46  return b;
47 }
48 
49 inline static
50 uint16_t uint16_swap_le_be_asm(const uint16_t a)
51 {
52  uint32_t b;
53 
54  __asm__ ("lhbrx %0,0,%1"
55  :"=r"(b)
56  :"r"(&a), "m"(a));
57 
58  return b;
59 }
60 
61 #define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
62 #define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
63 
64 #elif defined(__mc68000__) && defined(__STORMGCC__)
65 
66 inline static
67 uint32_t uint32_swap_le_be_asm(uint32_t a __asm__("d0"))
68 {
69  /* __asm__("rolw #8,%0; swap %0; rolw #8,%0" : "=d" (val) : "0" (val)); */
70 
71  __asm__("move.l %1,d0;rol.w #8,d0;swap d0;rol.w #8,d0;move.l d0,%0"
72  :"=r"(a)
73  :"r"(a));
74 
75  return(a);
76 }
77 
78 inline static
79 uint16_t uint16_swap_le_be_asm(uint16_t a __asm__("d0"))
80 {
81  __asm__("move.l %1,d0;rol.w #8,d0;move.l d0,%0"
82  :"=r"(a)
83  :"r"(a));
84 
85  return(a);
86 }
87 
88 #define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
89 #define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
90 
91 #elif 0 && defined(__i386__) && defined(__GNUC__)
92 
93 inline static
94 uint32_t uint32_swap_le_be_asm(uint32_t a)
95 {
96  __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
97  "rorl $16,%0\n\t" /* swap words */
98  "xchgb %b0,%h0" /* swap higher bytes */
99  :"=q" (a)
100  : "0" (a));
101 
102  return(a);
103 }
104 
105 inline static
106 uint16_t uint16_swap_le_be_asm(uint16_t a)
107 {
108  __asm__("xchgb %b0,%h0" /* swap bytes */
109  : "=q" (a)
110  : "0" (a));
111 
112  return(a);
113 }
114 
115 #define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
116 #define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
117 
118 #endif
119 
120 #endif /* !defined(DISABLE_ASM_OPTIMIZE) */
121 #endif /* __CDIO_BYTESEX_ASM_H__ */
122 
123 
124 /*
125  * Local variables:
126  * c-file-style: "gnu"
127  * tab-width: 8
128  * indent-tabs-mode: nil
129  * End:
130  */

Generated for libcdio by doxygen 1.8.1.1