ntohl.S revision 178580
174462Salfred/* $NetBSD: byte_swap_4.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */ 274462Salfred 374462Salfred/*- 474462Salfred * Copyright (c) 1997 The NetBSD Foundation, Inc. 574462Salfred * All rights reserved. 674462Salfred * 774462Salfred * This code is derived from software contributed to The NetBSD Foundation 874462Salfred * by Neil A. Carson 974462Salfred * 1074462Salfred * Redistribution and use in source and binary forms, with or without 1174462Salfred * modification, are permitted provided that the following conditions 1274462Salfred * are met: 1374462Salfred * 1. Redistributions of source code must retain the above copyright 1474462Salfred * notice, this list of conditions and the following disclaimer. 1574462Salfred * 2. Redistributions in binary form must reproduce the above copyright 1674462Salfred * notice, this list of conditions and the following disclaimer in the 1774462Salfred * documentation and/or other materials provided with the distribution. 1874462Salfred * 3. All advertising materials mentioning features or use of this software 1974462Salfred * must display the following acknowledgement: 2074462Salfred * This product includes software developed by the NetBSD 2174462Salfred * Foundation, Inc. and its contributors. 2274462Salfred * 4. Neither the name of The NetBSD Foundation nor the names of its 2374462Salfred * contributors may be used to endorse or promote products derived 2474462Salfred * from this software without specific prior written permission. 2574462Salfred * 2674462Salfred * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2774462Salfred * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2874462Salfred * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2974462Salfred * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 3074462Salfred * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 3174462Salfred * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 3274462Salfred * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33136581Sobrien * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3474462Salfred * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3574462Salfred * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3692990Sobrien * POSSIBILITY OF SUCH DAMAGE. 3792990Sobrien */ 3874462Salfred 3974462Salfred#include <machine/asm.h> 4074462Salfred 4174462Salfred__FBSDID("$FreeBSD: head/lib/libc/mips/net/ntohl.S 178580 2008-04-26 12:08:02Z imp $"); 4274462Salfred 4374462SalfredLEAF(ntohl) # a0 = 0x11223344, return 0x44332211 4474462Salfred#ifdef __MIPSEB__ 4574462Salfred move v0, a0 4674462Salfred#else 4775094Siedowse srl v1, a0, 24 # v1 = 0x00000011 4874462Salfred sll v0, a0, 24 # v0 = 0x44000000 4974462Salfred or v0, v0, v1 5074462Salfred and v1, a0, 0xff00 5174462Salfred sll v1, v1, 8 # v1 = 0x00330000 5274462Salfred or v0, v0, v1 5374462Salfred srl v1, a0, 8 54109359Smbr and v1, v1, 0xff00 # v1 = 0x00002200 5574462Salfred or v0, v0, v1 5674462Salfred#endif 5774462Salfred j ra 5874462SalfredEND(ntohl) 5974462Salfred