1178580Simp/* $NetBSD: byte_swap_2.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */ 2178580Simp 3178580Simp/*- 4178580Simp * Copyright (c) 1999 The NetBSD Foundation, Inc. 5178580Simp * All rights reserved. 6178580Simp * 7178580Simp * This code is derived from software contributed to The NetBSD Foundation 8178580Simp * by Charles M. Hannum. 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 * 3. All advertising materials mentioning features or use of this software 19178580Simp * must display the following acknowledgement: 20178580Simp * This product includes software developed by the NetBSD 21178580Simp * Foundation, Inc. and its contributors. 22178580Simp * 4. Neither the name of The NetBSD Foundation nor the names of its 23178580Simp * contributors may be used to endorse or promote products derived 24178580Simp * from this software without specific prior written permission. 25178580Simp * 26178580Simp * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27178580Simp * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28178580Simp * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29178580Simp * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30178580Simp * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31178580Simp * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32178580Simp * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33178580Simp * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34178580Simp * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35178580Simp * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36178580Simp * POSSIBILITY OF SUCH DAMAGE. 37178580Simp */ 38178580Simp 39178580Simp#include <machine/asm.h> 40178580Simp 41178580Simp__FBSDID("$FreeBSD$"); 42178580Simp 43178580SimpLEAF(htons) 44178580Simp#ifdef __MIPSEB__ 45178580Simp move v0, a0 46178580Simp#else 47178580Simp srl v0, a0, 8 48178580Simp and v0, v0, 0xff 49178580Simp sll v1, a0, 8 50178580Simp and v1, v1, 0xff00 51178580Simp or v0, v0, v1 52178580Simp#endif 53178580Simp j ra 54178580SimpEND(htons) 55