Commit | Line | Data |
---|---|---|
808d2265 KB |
1 | /*- |
2 | * Copyright (c) 1991 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * This code is derived from software contributed to Berkeley by | |
6 | * Ralph Campbell. | |
7 | * | |
8 | * %sccs.include.redist.c% | |
9 | */ | |
10 | ||
11 | #if defined(LIBC_SCCS) && !defined(lint) | |
12 | ASMSTR("@(#)htonl.s 5.1 (Berkeley) %G%") | |
13 | #endif /* LIBC_SCCS and not lint */ | |
14 | ||
15 | #include "DEFS.h" | |
16 | ||
17 | /* | |
18 | * netorder = htonl(hostorder) | |
19 | * hostorder = ntohl(netorder) | |
20 | */ | |
21 | LEAF(htonl) # a0 = 0x11223344, return 0x44332211 | |
22 | ALEAF(ntohl) | |
23 | srl v1, a0, 24 # v1 = 0x00000011 | |
24 | sll v0, a0, 24 # v0 = 0x44000000 | |
25 | or v0, v0, v1 | |
26 | and v1, a0, 0xff00 | |
27 | sll v1, v1, 8 # v1 = 0x00330000 | |
28 | or v0, v0, v1 | |
29 | srl v1, a0, 8 | |
30 | and v1, v1, 0xff00 # v1 = 0x00002200 | |
31 | or v0, v0, v1 | |
32 | j ra | |
33 | END(htonl) |