summaryrefslogtreecommitdiff
path: root/sys/lib/libkern/arch/mips/htonl.S
blob: afcb8e35620fcb1afb68d5e8ad4e07f60c2847d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*	$OpenBSD: htonl.S,v 1.5 1998/03/01 16:10:30 niklas Exp $	*/

#include "DEFS.h"


/*
 * netorder = htonl(hostorder)
 * hostorder = ntohl(netorder)
 */
LEAF(htonl)				# a0 = 0x11223344, return 0x44332211
ALEAF(ntohl)
	.set	noreorder
	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
	j	ra
	or	v0, v0, v1
END(htonl)