xref: /csrg-svn/lib/libc/mips/net/htonl.s (revision 52710)
1*52710Sbostic/*-
2*52710Sbostic * Copyright (c) 1991 The Regents of the University of California.
3*52710Sbostic * All rights reserved.
4*52710Sbostic *
5*52710Sbostic * This code is derived from software contributed to Berkeley by
6*52710Sbostic * Ralph Campbell.
7*52710Sbostic *
8*52710Sbostic * %sccs.include.redist.c%
9*52710Sbostic */
10*52710Sbostic
11*52710Sbostic#if defined(LIBC_SCCS) && !defined(lint)
12*52710Sbostic	ASMSTR("@(#)htonl.s	5.1 (Berkeley) 02/29/92")
13*52710Sbostic#endif /* LIBC_SCCS and not lint */
14*52710Sbostic
15*52710Sbostic#include "DEFS.h"
16*52710Sbostic
17*52710Sbostic/*
18*52710Sbostic * netorder = htonl(hostorder)
19*52710Sbostic * hostorder = ntohl(netorder)
20*52710Sbostic */
21*52710SbosticLEAF(htonl)				# a0 = 0x11223344, return 0x44332211
22*52710SbosticALEAF(ntohl)
23*52710Sbostic	srl	v1, a0, 24		# v1 = 0x00000011
24*52710Sbostic	sll	v0, a0, 24		# v0 = 0x44000000
25*52710Sbostic	or	v0, v0, v1
26*52710Sbostic	and	v1, a0, 0xff00
27*52710Sbostic	sll	v1, v1, 8		# v1 = 0x00330000
28*52710Sbostic	or	v0, v0, v1
29*52710Sbostic	srl	v1, a0, 8
30*52710Sbostic	and	v1, v1, 0xff00		# v1 = 0x00002200
31*52710Sbostic	or	v0, v0, v1
32*52710Sbostic	j	ra
33*52710SbosticEND(htonl)
34