1/* 2 * Copyright 2009, Johannes Wischert. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6#include <asm_defs.h> 7 8.text 9 10/* uint16 __swap_int16(uint16 value) 11 */ 12FUNCTION(__swap_int16): 13#if __ARM_ARCH__ >= 6 14 rev16 r0,r0; 15#else 16#warning IMPLEMENT_ME 17 and r1,r0,#0x000000ff 18 and r2,r0,#0x0000ff00 19 mov r1,r1,LSL #8 20 mov r2,r2,ROR #8 21 orr r0,r1,r2 22#endif 23 mov pc,lr 24FUNCTION_END(__swap_int16) 25 26/* uint32 __swap_int32(uint32 value) 27 */ 28FUNCTION(__swap_int32): 29#if __ARM_ARCH__ >= 6 30 rev r0,r0; 31#else 32#warning IMPLEMENT_ME 33 mov r3,#0xff000000 34 orr r3,#0x0000ff00 35 and r1,r0,r3 36 mov r1,r1,ROR #24 37 mov r3,r3,ROR #8 38 and r2,r0,r3 39 mov r2,r2,ROR #8 40 orr r0,r1,r2 41#endif 42 mov pc,lr 43FUNCTION_END(__swap_int32) 44 45/* uint64 __swap_int64(uint64 value) 46 */ 47FUNCTION(__swap_int64): 48#if __ARM_ARCH__ >= 6 49 rev r0,r0; 50 rev r1,r1; 51 mov r12,r0; 52 mov r0,r1; 53 mov r1,r12; 54#else 55#warning IMPLEMENT_ME 56#endif 57 mov pc,lr 58FUNCTION_END(__swap_int64) 59 60/* TODO: The following functions can surely be optimized. A simple optimization 61 * would be to define macros with the contents of the __swap_int{32,64} 62 * functions and use those instead of calling the functions. 63 */ 64 65/* float __swap_float(float value) 66 */ 67FUNCTION(__swap_float): 68 b __swap_int32 69 //rts 70FUNCTION_END(__swap_float) 71 72 73/* double __swap_double(double value) 74 */ 75FUNCTION(__swap_double): 76 b __swap_int32 77 //rts 78#warning M68K: XXX:check sizeof(double) 79FUNCTION_END(__swap_double) 80 81