152710Sbostic/*- 252710Sbostic * Copyright (c) 1991 The Regents of the University of California. 352710Sbostic * All rights reserved. 452710Sbostic * 552710Sbostic * This code is derived from software contributed to Berkeley by 652710Sbostic * Ralph Campbell. 752710Sbostic * 852710Sbostic * %sccs.include.redist.c% 952710Sbostic */ 1052710Sbostic 1152738Sbostic#include "DEFS.h" 1252738Sbostic 1352710Sbostic#if defined(LIBC_SCCS) && !defined(lint) 14*54153Sralph ASMSTR("@(#)htonl.s 5.3 (Berkeley) 06/20/92") 1552710Sbostic#endif /* LIBC_SCCS and not lint */ 1652710Sbostic 17*54153Sralph#include <machine/endian.h> 18*54153Sralph#undef htonl 19*54153Sralph#undef ntohl 20*54153Sralph 2152710Sbostic/* 2252710Sbostic * netorder = htonl(hostorder) 2352710Sbostic * hostorder = ntohl(netorder) 2452710Sbostic */ 2552710SbosticLEAF(htonl) # a0 = 0x11223344, return 0x44332211 2652710SbosticALEAF(ntohl) 27*54153Sralph#if BYTE_ORDER == LITTLE_ENDIAN 2852710Sbostic srl v1, a0, 24 # v1 = 0x00000011 2952710Sbostic sll v0, a0, 24 # v0 = 0x44000000 3052710Sbostic or v0, v0, v1 3152710Sbostic and v1, a0, 0xff00 3252710Sbostic sll v1, v1, 8 # v1 = 0x00330000 3352710Sbostic or v0, v0, v1 3452710Sbostic srl v1, a0, 8 3552710Sbostic and v1, v1, 0xff00 # v1 = 0x00002200 3652710Sbostic or v0, v0, v1 37*54153Sralph#else 38*54153Sralph#if BYTE_ORDER == BIG_ENDIAN 39*54153Sralph move v0, a0 40*54153Sralph#else 41*54153Sralph ERROR 42*54153Sralph#endif 43*54153Sralph#endif 4452710Sbostic j ra 4552710SbosticEND(htonl) 46