Re: Bit order == byte order??
Erik Trulsson ertr1...@student.uu.se wrote: On Thu, Mar 03, 2011 at 11:26:12AM -0500, Frank Solensky wrote: In sys/netinet/ip.h, the first octet of the ip header structure tests the byte ordering to determine the ordering of the header length (ip_hl) and version (ip_v) fields. My question: that always works? While my reading of the language specification document leaves both the ordering of the bits within a byte and the bytes within a longer field as implementation choices, the two are independent of each other. I haven't run into a CPU where this assumption was proven incorrect ... Unless you have a CPU where memory is addressed bit-by-bit rather than byte-by-byte the ordering of bits within a byte is not only completely irrelevant, it is also pretty much impossible to determine programatically. Agreed it is at least difficult to determine programatically, however it is quite important when dealing with hardware that converts between a sequence of bytes and a bitstream, e.g. serial ports, network interfaces, SATA ports. Driver writers had _better_ know which bit of the byte, as well as which byte of a word/longword/quadword, is going on the wire first. The O.P. is absolutely correct that bit order within a byte and byte order within a multibyte field need not, in principle, be the same. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Bit order == byte order??
On Fri, Mar 04, 2011 at 01:09:23AM -0800, per...@pluto.rain.com wrote: Erik Trulsson ertr1...@student.uu.se wrote: On Thu, Mar 03, 2011 at 11:26:12AM -0500, Frank Solensky wrote: In sys/netinet/ip.h, the first octet of the ip header structure tests the byte ordering to determine the ordering of the header length (ip_hl) and version (ip_v) fields. My question: that always works? While my reading of the language specification document leaves both the ordering of the bits within a byte and the bytes within a longer field as implementation choices, the two are independent of each other. I haven't run into a CPU where this assumption was proven incorrect ... Unless you have a CPU where memory is addressed bit-by-bit rather than byte-by-byte the ordering of bits within a byte is not only completely irrelevant, it is also pretty much impossible to determine programatically. Agreed it is at least difficult to determine programatically, however it is quite important when dealing with hardware that converts between a sequence of bytes and a bitstream, e.g. serial ports, network interfaces, SATA ports. Driver writers had _better_ know which bit of the byte, as well as which byte of a word/longword/quadword, is going on the wire first. Although it certainly matters for serial I/O devices which bit goes out first on the wire, you only need to know if the I/O hardware will push out data with the most significant bit first or the least significant bit first and possibly adjust the values you write to the I/O hardware if it does not match the order you want the bits to go out. You still don't need to know anything about in which order bits are stored in a byte inside the CPU or in RAM. -- Insert your favourite quote here. Erik Trulsson ertr1...@student.uu.se ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Bit order == byte order??
In sys/netinet/ip.h, the first octet of the ip header structure tests the byte ordering to determine the ordering of the header length (ip_hl) and version (ip_v) fields. My question: that always works? While my reading of the language specification document leaves both the ordering of the bits within a byte and the bytes within a longer field as implementation choices, the two are independent of each other. I haven't run into a CPU where this assumption was proven incorrect. It just surprised me to see that recently___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Bit order == byte order??
On Thu, Mar 03, 2011 at 11:26:12AM -0500, Frank Solensky wrote: In sys/netinet/ip.h, the first octet of the ip header structure tests the byte ordering to determine the ordering of the header length (ip_hl) and version (ip_v) fields. My question: that always works? While my reading of the language specification document leaves both the ordering of the bits within a byte and the bytes within a longer field as implementation choices, the two are independent of each other. I haven't run into a CPU where this assumption was proven incorrect. It just surprised me to see that recently Unless you have a CPU where memory is addressed bit-by-bit rather than byte-by-byte the ordering of bits within a byte is not only completely irrelevant, it is also pretty much impossible to determine programatically. -- Insert your favourite quote here. Erik Trulsson ertr1...@student.uu.se ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org