1/* 2** Copyright 2003, Axel D�fler, axeld@pinc-software.de. All rights reserved. 3** Distributed under the terms of the OpenBeOS License. 4*/ 5 6#include <asm_defs.h> 7 8.text 9 10/* uint16 __swap_int16(uint16 value) 11 */ 12FUNCTION(__swap_int16): 13 moveq.l #0,%d0 14 /* 32-bit aligned stack! */ 15 move.l (4,%a7),%d1 16 move.b %d1,%d0 17 lsr.w #8,%d1 18 lsl.w #8,%d0 19 move.b %d1,%d0 20 rts 21FUNCTION_END(__swap_int16) 22 23/* uint32 __swap_int32(uint32 value) 24 */ 25FUNCTION(__swap_int32): 26/* moveq.l #0,%d0*/ 27 move.b (7,%a7),%d0 28 lsl.l #8,%d0 29 move.b (6,%a7),%d0 30 lsl.l #8,%d0 31 move.b (5,%a7),%d0 32 lsl.l #8,%d0 33 move.b (4,%a7),%d0 34 rts 35FUNCTION_END(__swap_int32) 36 37/* uint64 __swap_int64(uint64 value) 38 */ 39FUNCTION(__swap_int64): 40/* moveq.l #0,%d0*/ 41 move.b (7,%a7),%d1 42 lsl.l #8,%d1 43 move.b (6,%a7),%d1 44 lsl.l #8,%d1 45 move.b (5,%a7),%d1 46 lsl.l #8,%d1 47 move.b (4,%a7),%d1 48 /**/ 49 move.b (11,%a7),%d0 50 lsl.l #8,%d0 51 move.b (10,%a7),%d0 52 lsl.l #8,%d0 53 move.b (9,%a7),%d0 54 lsl.l #8,%d0 55 move.b (8,%a7),%d0 56 rts 57FUNCTION_END(__swap_int64) 58 59/* TODO: The following functions can surely be optimized. A simple optimization 60 * would be to define macros with the contents of the __swap_int{32,64} 61 * functions and use those instead of calling the functions. 62 */ 63 64/* float __swap_float(float value) 65 */ 66FUNCTION(__swap_float): 67 jmp __swap_int32 68 //rts 69FUNCTION_END(__swap_float) 70 71 72/* double __swap_double(double value) 73 */ 74FUNCTION(__swap_double): 75 jmp __swap_int32 76 //rts 77#warning M68K: XXX:check sizeof(double) 78FUNCTION_END(__swap_double) 79 80