From 808d22657a5de792629e007f539e43e20dd19f4d Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Sat, 29 Feb 1992 20:43:13 -0800 Subject: [PATCH] date and time created 92/02/29 12:43:13 by bostic SCCS-vsn: lib/libc/mips/net/htonl.s 5.1 --- usr/src/lib/libc/mips/net/htonl.s | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 usr/src/lib/libc/mips/net/htonl.s diff --git a/usr/src/lib/libc/mips/net/htonl.s b/usr/src/lib/libc/mips/net/htonl.s new file mode 100644 index 0000000000..bc0ece5d37 --- /dev/null +++ b/usr/src/lib/libc/mips/net/htonl.s @@ -0,0 +1,33 @@ +/*- + * Copyright (c) 1991 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * %sccs.include.redist.c% + */ + +#if defined(LIBC_SCCS) && !defined(lint) + ASMSTR("@(#)htonl.s 5.1 (Berkeley) %G%") +#endif /* LIBC_SCCS and not lint */ + +#include "DEFS.h" + +/* + * netorder = htonl(hostorder) + * hostorder = ntohl(netorder) + */ +LEAF(htonl) # a0 = 0x11223344, return 0x44332211 +ALEAF(ntohl) + srl v1, a0, 24 # v1 = 0x00000011 + sll v0, a0, 24 # v0 = 0x44000000 + or v0, v0, v1 + and v1, a0, 0xff00 + sll v1, v1, 8 # v1 = 0x00330000 + or v0, v0, v1 + srl v1, a0, 8 + and v1, v1, 0xff00 # v1 = 0x00002200 + or v0, v0, v1 + j ra +END(htonl) -- 2.20.1