I wrote the TCP / IP stack for the UNIVAC 1100 universal mainframe many years ago. It was a 36-bit, addressable computer architecture with 1 arithmetic.
When this unit was doing message input / output, 8-bit bytes coming from the outside world would fall into the lower 8 bits of each 9-bit quarter of a word. Therefore, in this system, ntohl () will compress 8 bits in every fourth word down to the lower 32 bits of the word (with the top 4 bits of zero) so that you can do arithmetic on it.
Similarly, htonl () will take the low 32 bits in a word and cancel this operation to put every 8-bit count in the low 8 bits of every 9-bit fourth word.
So, to answer the original question, the ntohl () and htonl () operations in this computer architecture were very different from each other.
For example:
COMP* . COMPRESS A WORD LSSL A0,36 . CLEAR OUT A0 LSSL A1,1 . THROW AWAY TOP BIT LDSL A0,8 . GET 8 GOOD ONE'S LSSL A1,1 . LDSL A0,8 . LSSL A1,1 . LDSL A0,8 . LSSL A1,1 . LDSL A0,8 . J 0,X9 . . DCOMP* . DECOMPRESS A WORD LSSL A0,36 . CLEAR A0 LSSL A1,4 . THROW OUT NOISE LDSL A0,8 . MOVE 8 GOOD BITS LSSL A0,1 . ADD 1 NOISE BIT LDSL A0,8 . MOVE 8 GOOD BITS LSSL A0,1 . ADD 1 NOISE BIT LDSL A0,8 . MOVE 8 GOOD BITS LSSL A0,1 . ADD 1 NOISE BIT LDSL A0,8 . MOVE 8 GOOD BITS J 0,X9 .
COMP is the equivalent of ntohl () and DCOMP for htonl (). For those who are not familiar with the UNIVAC 1100 build code :-) LSSL is a "Left Single Shift Logical" register in several positions. LDSL - "Left Double Shift Logical" - a pair of registers on the specified account. Thus, LDSL A0.8 shifts the concatenated registers A0, A1, leaving 8 bits, shifting the high 8 bits of A1 to the lower 8 bits of A0.
This code was written in 1981 for UNIVAC 1108. A few years later, when we had 1100/90 and the C compiler grew up, I started the BSD NET / 2 TCP / IP implementation port and implemented ntohl () and htonl () similarly way. Unfortunately, I have never completed this work.
If you are wondering why some of the Internet RFCs use the term “octet”, it is because on some computers per day (for example, PDP-10, Univacs, etc.) there were “bytes” that were not 8 bits. An "octet" was specifically defined for an 8-bit byte.