diff --git a/src/system/libroot/os/arch/m68k/byteorder.S b/src/system/libroot/os/arch/m68k/byteorder.S index 330494a3c2..5c04129ffb 100644 --- a/src/system/libroot/os/arch/m68k/byteorder.S +++ b/src/system/libroot/os/arch/m68k/byteorder.S @@ -7,73 +7,42 @@ .text -/* uint16 __swap_int16(uint16 value) - */ -FUNCTION(__swap_int16): - moveq.l #0,%d0 - /* 32-bit aligned stack! */ - move.l (4,%a7),%d1 - move.b %d1,%d0 - lsr.w #8,%d1 - lsl.w #8,%d0 - move.b %d1,%d0 - rts -FUNCTION_END(__swap_int16) - -/* uint32 __swap_int32(uint32 value) - */ -FUNCTION(__swap_int32): -/* moveq.l #0,%d0*/ - move.b (7,%a7),%d0 - lsl.l #8,%d0 - move.b (6,%a7),%d0 - lsl.l #8,%d0 - move.b (5,%a7),%d0 - lsl.l #8,%d0 - move.b (4,%a7),%d0 - rts -FUNCTION_END(__swap_int32) - -/* uint64 __swap_int64(uint64 value) - */ -FUNCTION(__swap_int64): -/* moveq.l #0,%d0*/ - move.b (7,%a7),%d1 - lsl.l #8,%d1 - move.b (6,%a7),%d1 - lsl.l #8,%d1 - move.b (5,%a7),%d1 - lsl.l #8,%d1 - move.b (4,%a7),%d1 - /**/ - move.b (11,%a7),%d0 - lsl.l #8,%d0 - move.b (10,%a7),%d0 - lsl.l #8,%d0 - move.b (9,%a7),%d0 - lsl.l #8,%d0 - move.b (8,%a7),%d0 - rts -FUNCTION_END(__swap_int64) - -/* TODO: The following functions can surely be optimized. A simple optimization - * would be to define macros with the contents of the __swap_int{32,64} - * functions and use those instead of calling the functions. - */ /* float __swap_float(float value) */ FUNCTION(__swap_float): - jmp __swap_int32 - //rts +/* moveq.l #0,%d0*/ + move.b (7,%a7),%d0 + lsl.l #8,%d0 + move.b (6,%a7),%d0 + lsl.l #8,%d0 + move.b (5,%a7),%d0 + lsl.l #8,%d0 + move.b (4,%a7),%d0 + rts FUNCTION_END(__swap_float) /* double __swap_double(double value) */ FUNCTION(__swap_double): - jmp __swap_int32 - //rts +/* moveq.l #0,%d0*/ + move.b (7,%a7),%d1 + lsl.l #8,%d1 + move.b (6,%a7),%d1 + lsl.l #8,%d1 + move.b (5,%a7),%d1 + lsl.l #8,%d1 + move.b (4,%a7),%d1 + /**/ + move.b (11,%a7),%d0 + lsl.l #8,%d0 + move.b (10,%a7),%d0 + lsl.l #8,%d0 + move.b (9,%a7),%d0 + lsl.l #8,%d0 + move.b (8,%a7),%d0 + rts #warning M68K: XXX:check sizeof(double) FUNCTION_END(__swap_double) diff --git a/src/system/libroot/os/arch/ppc/byteorder.S b/src/system/libroot/os/arch/ppc/byteorder.S index 8f1b1536b8..c8a6d8824d 100644 --- a/src/system/libroot/os/arch/ppc/byteorder.S +++ b/src/system/libroot/os/arch/ppc/byteorder.S @@ -7,46 +7,6 @@ .text -/* uint16 __swap_int16(uint16 value) - * r3 - */ -FUNCTION(__swap_int16): - rlwinm %r4, %r3, 8, 16, 23 // byte 4 -> byte 3 (clear other bits) - rlwimi %r4, %r3, 24, 24, 31 // byte 3 -> byte 4 (copy into) - mr %r3, %r4 // copy to result register - blr - - -/* uint32 __swap_int32(uint32 value) - * r3 - */ -FUNCTION(__swap_int32): - rlwinm %r4, %r3, 24, 0, 31 // byte 4 to 1, byte 2 to 3 - rlwimi %r4, %r3, 8, 8, 15 // byte 3 to 2 - rlwimi %r4, %r3, 8, 24, 31 // byte 1 to 4 - mr %r3, %r4 - blr - - -/* uint64 __swap_int64(uint64 value) - * r3/r4 - */ -FUNCTION(__swap_int64): - rlwinm %r5, %r3, 24, 0, 31 // byte 4 to 5, byte 2 to 7 - rlwimi %r5, %r3, 8, 8, 15 // byte 3 to 6 - rlwimi %r5, %r3, 8, 24, 31 // byte 1 to 8 - rlwinm %r3, %r4, 24, 0, 31 // byte 8 to 1, byte 6 to 3 - rlwimi %r3, %r4, 8, 8, 15 // byte 7 to 2 - rlwimi %r3, %r4, 8, 24, 31 // byte 5 to 4 - mr %r4, %r5 // copy lower 32 bits - blr - - -/* TODO: The following functions can surely be optimized. A simple optimization - * would be to define macros with the contents of the __swap_int{32,64} - * functions and use those instead of calling the functions. - */ - /* float __swap_float(float value) * f1 */ diff --git a/src/system/libroot/os/arch/x86_64/byteorder.S b/src/system/libroot/os/arch/x86_64/byteorder.S index 9b346809fa..27066a6adf 100644 --- a/src/system/libroot/os/arch/x86_64/byteorder.S +++ b/src/system/libroot/os/arch/x86_64/byteorder.S @@ -7,28 +7,6 @@ #include -/* uint16 __swap_int16(uint16 value) */ -FUNCTION(__swap_int16): - movl %edi, %eax - bswap %eax - shr $16, %eax - ret -FUNCTION_END(__swap_int16) - -/* uint32 __swap_int32(uint32 value) */ -FUNCTION(__swap_int32): - movl %edi, %eax - bswap %eax - ret -FUNCTION_END(__swap_int32) - -/* uint64 __swap_int64(uint64 value) */ -FUNCTION(__swap_int64): - movq %rdi, %rax - bswap %rax - ret -FUNCTION_END(__swap_int64) - /* float __swap_float(float value) */ FUNCTION(__swap_float): sub $8, %rsp