1178580Simp/* $NetBSD: byte_swap_4.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */ 2178580Simp 3178580Simp/*- 4178580Simp * Copyright (c) 1997 The NetBSD Foundation, Inc. 5178580Simp * All rights reserved. 6178580Simp * 7178580Simp * This code is derived from software contributed to The NetBSD Foundation 8178580Simp * by Neil A. Carson 9178580Simp * 10178580Simp * Redistribution and use in source and binary forms, with or without 11178580Simp * modification, are permitted provided that the following conditions 12178580Simp * are met: 13178580Simp * 1. Redistributions of source code must retain the above copyright 14178580Simp * notice, this list of conditions and the following disclaimer. 15178580Simp * 2. Redistributions in binary form must reproduce the above copyright 16178580Simp * notice, this list of conditions and the following disclaimer in the 17178580Simp * documentation and/or other materials provided with the distribution. 18178580Simp * 19178580Simp * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20178580Simp * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21178580Simp * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22178580Simp * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23178580Simp * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24178580Simp * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25178580Simp * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26178580Simp * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27178580Simp * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28178580Simp * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29178580Simp * POSSIBILITY OF SUCH DAMAGE. 30178580Simp */ 31178580Simp 32178580Simp#include <machine/asm.h> 33178580Simp 34178580Simp__FBSDID("$FreeBSD: releng/11.0/lib/libc/mips/net/ntohl.S 251091 2013-05-29 01:54:10Z emaste $"); 35178580Simp 36178580SimpLEAF(ntohl) # a0 = 0x11223344, return 0x44332211 37178580Simp#ifdef __MIPSEB__ 38178580Simp move v0, a0 39178580Simp#else 40178580Simp srl v1, a0, 24 # v1 = 0x00000011 41178580Simp sll v0, a0, 24 # v0 = 0x44000000 42178580Simp or v0, v0, v1 43178580Simp and v1, a0, 0xff00 44178580Simp sll v1, v1, 8 # v1 = 0x00330000 45178580Simp or v0, v0, v1 46178580Simp srl v1, a0, 8 47178580Simp and v1, v1, 0xff00 # v1 = 0x00002200 48178580Simp or v0, v0, v1 49178580Simp#endif 50178580Simp j ra 51178580SimpEND(ntohl) 52