When and why did hexadecimal representation become more common than octal for displaying and printing out multi-bit binary fields?
5 Answers
Addressing the "why" part of the question - from my point of view as an assembly-code programmer on PDP-11 and VAX, the "standard" radix is most usefully chosen to match the instruction layout.
PDP-11 had 8 registers and 8 operand-mode indicators. Its double-operand instruction layout was
1 bit generally byte/word indicator (b)
3 bits opcode (o)
3 bits source mode (s)
3 bits source register (r)
3 bits destination mode (d)
3 bits destination register (R)
making octal the perfect way to express it:
booosssrrrdddRRR
The VAX, on the other hand, had 16 registers and 16 bits for operand mode (though some combinations were used for short literals). A basic operand specifier, in the variable-length instruction format was
4 bits mode (m)
4 bits register (r)
thus hex was perfect to express these.
mmmmrrrr
Of course, the larger address space used on VAX gives other advantages to hex: fewer characters in an address. This might have some bearing on "when".
- 35,301
- 3
- 80
- 160
-
7x86 instruction set is also more usefully thought of as octal-encoded (see e.g. here), but hex is still the most common non-decimal non-binary radix in assembly programs written for it. Some assemblers don't even have a syntax for creating octal literals. – Ruslan Aug 21 '19 at 08:33
-
Not sure that applied to Prime. I think that was just "what they were used to". – Martin Bonner supports Monica Aug 21 '19 at 13:26
The when and why of use of hexadecimal over octal representation is intimately tied in with where and what: the use of one over the other depended greatly on environmental factors, as well as the machine itself, with programmer preference mainly being developed by the influence of these.
As Raffzahan points out, IBM 360 environments used hexadecimal from their start in the early 60s. This did not particularly influence other computing environments (particularly minicomputers) because IBM at that point was still its own separate world within computing for both technical reasons (e.g., using EBCDIC instead of ASCII) and because, despite the 1956 consent decree, they were still successfully using various measures to stifle compatibility and competition. (This wouldn't start to change in a serious way until the various lawsuits started pouring out in 1968 and 1969.)
Octal was a good fit for DEC minicomputers and early "micro-sized" machines (such as the PDP-8) because of their word sizes (18, 36 and 12 bits). Existing systems were naturally used to help develop new platforms, and thus new platforms after these would tend to inherit the octal versus hexadecimal choice from the existing ones. Famously, early versions of Microsoft Basic were assembled on a PDP-10 using MACRO-10, which didn't support hexadecimal, and so the source code used octal throughout where the bit values were considered important to the programmer, despite hexadecimal being the preferred number base for all of the first three CPUs (8080, 6800, 6502) for which it was written.
The same was true of the PDP-11, which was DEC's first major computer where the various word sizes were all multiple of 4 bits rather than 3. Even though software development rapidly moved to being done on the PDP-11 itself, DEC environments up to that time had been entirely octal, and so with programmers of DEC equipment mostly being more comfortable with that, it "stuck." (While other-dave points out that the bitfields in the instructions tended to be 3 bits wide, I don't buy this as a major factor; by 1970 hand-assembly was rare for machines of minicomputer size and up, in which category the PDP-11 indubitably fell.)
My guess is that the "it's what I'm used to" effect was at least part
of the reason for the front panel of the original Altair 8800 being
clearly organized for octal, despite Intel using hexadecimal
throughout the 8080's documentation. However, there were a
number of instructions, particularly MOV, with three-bit fields
aligned with octal, so perhaps they did also have in mind that people
might be hand-assembling to octal for this reason. (The typical Altair
owner was unlikely to have another, larger computer handy for
cross-development.)
(Source: Wikimedia Commons.)
That said, the awkwardness here is apparent if you open the image in a new tab and look at the upper set of markings ("SENSE SW" and "DATA") underneath the switches themselves; the split between the two 8-switch halves falls in the middle of one of the groups of three. (The owner of this system was obviously annoyed enough by the octal layout that he added tape to the front panel to visually indicate four groups of four!)
The 6800-based Altair 680B, released barely a year later, had already switched to panel markings that grouped the switches in fours, rather than threes.
By the late 70s the 8080/6800/6502 and their various progeny were starting to dominate the computing landscape, at least as far as numbers goes, and because they in particular tended toward use of hexadecimal it became more likely that's what a programmer would be comfortable with if he were not equally comfortable with both. But as fadden points out in a comment, even into the 90s there were still environments where octal was the norm and hexadecimal was generally rejected.
This continues to this day in certain areas where it's unlikely ever
to change because octal is significantly easier to read than
hexadecimal. For example, the POSIX file permission bits are a group
of two bits for sgid/suid followed by three groups of three bits for
owner/group/other permissions of read/write/execute: these are
normally and most easily specified (both for command line tools such
as chmod and when programming) as four octal digits.
So if you're going to try to treat the computing community as monolithic, and just go on the number of programmers that preferred one over the other, I'd agree with Chromatix that the "shift" happened in the mid- to late-70s. But I think that is probably too simplistic a way of looking at it to be a particularly valuable insight.
-
2Me again! by 1970 hand-assembly was rare Indeed it was, but debugging kernel code tended to use a little lights-and-switches work on the front panel, and a lot of poring over memory dumps. Kernel debuggers (XDT on 11M) did not disassemble code, so hand-disassembly was an occasional thing. Lastly, I don't want to over-sell it, but the ability to think hmm, that alleged data sure looks like instructions was a useful skill. – dave Aug 21 '19 at 12:13
-
"IBM at that point was still its own separate world within computing" Not really, if at all, IBM was the continental force, while there were islands that maintained difference. _"using EBCDIC instead of ASCII" - again not really, as EBCDIC was only used within the mainframe system. External communication was done by default in ASCII. This included not only all terminal peripherals, but any kind of third party sub system connection. Heck, the mainframes itself could be switched to ASCII handling. So while IBM did everything they could to stop competition, shuning ASCII wasn't one of them. – Raffzahn Aug 21 '19 at 13:05
-
Nice point with the Altait and even more so nice lighted picture- sourced from where? Oh, and +2 for the 'monolithic' remark. – Raffzahn Aug 21 '19 at 13:09
-
@Raffzahn Good point: the URL of the image itself isn't a good source attribution. I've added a link to the Wikimedia Commons category where I found it. Looking there, later panels did clean up the labeling slightly, but that doesn't help much. Toggling a few small programs into this simulator demonstrated to my satisfaction that the grouping into 3s is more of a pain than a help when entering instructions, even when working from an opcode list in binary, because of S7 being in the middle of a group of three. – cjs Aug 21 '19 at 13:39
-
Oh, it's not just the 8080 that reads nice in octal. The 6502 would do as well, asit's encoding follows a basic 3-3-2 scheme – Raffzahn Aug 21 '19 at 17:50
-
@Raffzahn Except that octal divides the bitfields 2-3-3, not 3-3-2. So hex splits one of the fields across two digits, whereas octal splits two of the fields across two digits. – cjs Aug 21 '19 at 22:45
-
@CurtJ.Sampson Note I said 'would', not 'does'. For sure Hex never works to show this structure on either CPU. – Raffzahn Aug 21 '19 at 23:32
-
@Raffzahn Ah, so you meant, "octal would show this for the 6502 if it did, but it doesn't." I think you can say the same about pretty much anything. :-P At any rate, there's not really enough structure in the 6502 opcode map for either to be fully regular, but hex certainly groups opcodes better than octal. – cjs Aug 22 '19 at 02:23
-
@CurtJ.Sampson Not really. 4040, 8048 and 6800/02 are 4-4 (hex). 6502 is 3-3-2 with the middle group selecting addressing mode, while first and last group operations (and all unused operations are last group 11). Hex ordered tables don't really show this. Try to make a table the octal way and you'll be surprised. It's almost as if they had ordered it octal when designing and later inverted the sequence of digits for ROM/PLA implementation. – Raffzahn Aug 22 '19 at 09:57
-
@Raffzahn "Try to make a table the octal way and you'll be surprised." Really? The second time I do it it's going to to be different from the octal table I made before I made my last repsonse? I'm kinda feeling it's going to come out the same: more bitfields split across digits in octal than in hexadecimal. – cjs Aug 22 '19 at 16:22
-
@CurtJ.Sampson Not sure, as the table you posted was hex. Maybe take a look at this table I made it many years ago. Not perfect, but by using the relevant bitgrouping structures do show up quite well. – Raffzahn Aug 22 '19 at 18:48
-
@another-dave - quite correct about octal being appropriate for debugging, e.g., with DDT. – davidbak Aug 22 '19 at 22:39
-
@Raffzahn Yes, that's pretty similar to what I came up with. As I did, you've grouped it as 3-3-2, and you can't read octal directly off of this. To get the octal opcode for
STA zp,Xyou start with the bottom two bits,01, and combine it with the LSB of the next group,100, to get001, octal 1. That leaves you with10from the second group, and so you take the LSB of the third group110and combine it with the second to get010octal 2. That leaves the two bits11from the third group, octal 3, so your full opcode is 321. What this is useful for, I have no idea. – cjs Aug 23 '19 at 05:19 -
@CurtJ.Sampson Taking a step back from some dogma and try to see the beyond is always helpful to find structure and information. This starts with bit order. There have been many companies naming them left to right, isn't it? And in case of the 6502, the ordering might come way more natural when looking at the ROM/PLA structure and how the data lines have been layed from IR to group decoder and ROM. By moving the group bits down less cross overs and a better area use was archived. – Raffzahn Aug 27 '19 at 08:12
When and why
That is quite close tied to the IBM /360 and its introduction in 1964. The /360 is based on the use of an 8 bit byte, 32 bit word (16 bit half word) and 24 bit address. Thus all basic memory items were multiples of 8 bit units - which are, without any remainder, best be displayed in hex. In addition displaying bytes in hex correlates well with the main reason to use 8 bit bytes as well: the usage to store two BCD in one byte (*1). A hex dump will show them as easy readable numerals - while the rest is code anyway. The same way it works for (half, double) words. In a dump they can be read and decoded as what they are without any additional concern (*2). In octal a word displayed as bytes, like in a dump, will get a different numeric expression than displayed as a (half, double) word (*3). Effectively the same reasoning why decimal isn't used in the first place (*4).
Before that size of bytes, half words and words were (more often than not) multiples of 3, which works quite fine with octal. After all, grown up with decimal it's way less mental work to not use two numbers, than to learn six more. It seams more natural, doesn't it?
After that next to all new designs switched to 8 bit bytes to allow easy data exchange with IBM mainframes. This happened even faster for mini computers as they where usually supplementary systems to (/360ish) mainframes.
Additional thought about the transition and it being different due environment.
Another-dave made the point that he'managed to cope with octal [on a PDP-11]', noting the prevalence of octal in an DEC envirionment even way later. Thinking of, the PDP-11 is a rather late comer to his as being from 1970. At that time the 6 to 8 bit byte was done history - likewise the switch to hex - for major suppliers. In fact, the PDP-11 marks that spot in DEC history. But DEC as a company (and its machines users) made a rather smooth transition from 6/12/36 bit computers to 8/16/32 bit - DEC did not only continue to support their existing line, but also continued to sell and even develop new models of their 36 bit line well into the 1980s.
In contrast with IBM the switch was done in a brutal manner as the /360 not only almost killed the company but in turn replaced any other (mainframe) architecture. After that 8 bit (and hex) was rolled out across all new products and everything else eliminated quite fast. Some 'islands' remained with existing supercomuter installations into the early 1970s but got moved either to /360 or non-IBM (often CDC/Cray). Some of the later carrying on for more years with octal representation.
Almost anyone entering the market after 1964 did start with 8 bit bytes and hex notion for binary data. This is (as Curt notes) especially true for micro-computers, as next to all of them started with 8 bit bytes and their OSes/UIs preferring hex notation.
So while the general turning point it quite clear and fixed in time with IBMs choice for an 8 bit byte holding two BCD, adoption did vary across manufacturers, its user base and application areas.
Adoption of changes by humans are always gradual .. keep in mind, even after 100+ years of road regulation and harmonisation, there are still countries with right-hand traffic :))
See also this question about the rational of 36 bit designs. While not a true duplicate, it's quite related here.
*1 - Previous machines (often) stored one decimal per 6 bit byte, thus wasting more than 1/3 of memory when handling decimal (which was a major task - after all, accountants always got the computers first, not scientists). By switching to 8 bit bytes, holding two nibbles with one decimal each, memory usage was close to optimum without resorting to base 100 (7 bit byte) or base 1000 (10 bit byte).
*2 - Beyond byte sex that is
*3 - For example the Number 1024(Dec) is 0401(Hex Word) and 04 01 (Hex Byte) but002001 (Oct Word) and 004 001 (Oct Byte)
*4 - BASIC programmers on home computers offer an additional nice example here, as many of them used assembly as series of PEEKs and POKEs expressed in decimal numbers. I met more than one who was fluent in 6502 assembly, still I had a hard time understanding their all decimal opcode numbers :))
-
Being a PDP-11 hack (16-bit virtual, 18- or 22-bit physical), I sincerely don't understand the "multiple of 3" argument. We managed to cope quite well with the high digit being no greater than 1 or 3. – dave Aug 21 '19 at 03:08
-
@another-dave Yes, but even in your own words you "managed to cope," rather than saying you felt octal worked as well or better. Beyond what you described in your answer, within DEC there were good reasons to use octal over hex (e.g., the MACRO-10 assembler, which was at least sometimes used to cross-assemble for other platforms, didn't support hex). But if you look at just the display of data for power-of-2 word sizes, with no other factors involved, would you ever chose octal over hex? – cjs Aug 21 '19 at 08:06
-
@another-dave the multiple of 3 argument is in favour of octal, meaning that people tended to create architectures that used byte/word sizes as multiples thereof. It's not any comment about the usablity of octal itself on other architectures - the argument is (like most historical) non reversible. – Raffzahn Aug 21 '19 at 11:20
-
"Managed to cope" is English sarcasm, sorry about that. The multiple-of-3-bits argument seems to me like saying decimal is not well-suited to represent the number of eggs in a box, because it's not a power of ten. – dave Aug 21 '19 at 12:08
-
@another-dave Maybe I've been as well to subtile, so more blunt: The point can not be made backwards. Of course on can use octal for any kind of byte size - like hex or decimal or whatsoever. It was the use of octal that made multiple of three word sizes desirable. And of course using any number base for a single egg boxes (our markets BTW sell egg boxes of 10 - SCNR), but it does make sense if its one that uses each digit to the full - see the example I added for octal on byte vs. word usage. – Raffzahn Aug 21 '19 at 12:50
-
@Raffzahn - seems I misconstrued the direction of your argument; apologies. I don't buy that octal -> multiple-of-three either though. I suggest rather that character size = 6 bits -> multiple-of-six word size. (Blunt is ok, by the way) – dave Aug 21 '19 at 22:49
-
@another-dave Communication thru a limited channel like this is always error prone. Now, the 6 bit argument only proves the rule of octal prefered base. 6 bit characters basically call to have their binary value displayed in oct - any other system would be less good, wouldn't it? – Raffzahn Aug 21 '19 at 23:29
-
Yes, but I say "6 bit char -> octal" and also "6 bit char -> mult-of-6 word", not "6 bit char -> octal -> mult-of-6 word". But that's enough from me, I think. – dave Aug 21 '19 at 23:46
-
Within Cray Research / SGI / Cray Inc we did use octal into the 21st Century for machine instruction representation. The stated reason was that Seymour Cray said "I like octal." Given that the company name was Cray Research, that was that :) – Edward Barnard Aug 26 '19 at 16:30
-
1@EdwardBarnard After all, Cray(ish) machines did do multiple of 3 words for quite a long time, didn't they? – Raffzahn Aug 27 '19 at 08:06
-
@Raffzahn Indeed they did! CDC 6600 series was 60 bits. There were a lot of showoff features in the 64-bit CRAY-1, such as double precision being same as single precision. The real time clock was set to the number of clock ticks since the year zero AD. – Edward Barnard Aug 27 '19 at 14:35
Minicomputers and mainframes typically used octal, as many early mainframes had word sizes that were a multiple of 3 bits, and so did some minis. Operators and engineers within those environments became used to this, so even power-of-two word size minicomputers kept using octal.
Microcomputers, however, almost always had power-of-two word sizes for both address and data buses (or at least, a multiple of four bits), and there was a whole new generation of users who were not mentally locked into the mainframe/mini way of thinking. It was thus natural to start using hexadecimal instead.
You'll probably find, therefore, that hexadecimal rose to prominence about when microcomputers did, in the mid to late 1970s.
- 16,791
- 1
- 49
- 69
-
4Nah, we were using hex in the late 60s on IBM/360 and 370 systems. – Jim Garrison Aug 21 '19 at 07:04
-
-
1
-
Well, there are always exceptions from the norm. The question was about what the norm was. – Chromatix Aug 21 '19 at 18:04
-
As others stated, of course this is related to word size on your machine.
I started learning higher programming languages on a WANG 2200T in 1977, and everything was hexadecimal there. My "Junior Computer" in 1980 was programmed in 6502 assembly, and everything was hexadecimal there as well. The first time I heard about octal notation was when I learned C with the K&R book in 1982. And my understanding was that on older machines you would prefer octal to hexadecimal.
- 111
- 2
-
This doesn't strictly answer the question; it's more of an anecdote. Could you review [answer], and [edit] your answer to improve it? – wizzwizz4 Aug 21 '19 at 20:47
-
2But it's not, or at least not only, related to word size. Octal was the standard for the PDP-11 despite it having 16-bit words. The Altair 8800 front panel and all documentation shiped by MITS used octal exclusively, despite the Intel 8080 using 8- and 16-bit words and Intel using hexadecimal in manuals and data sheets on which MITS relied.And the IBM 360 was a much older machine than any of these yet there you preferred hexadecimal to octal. – cjs Aug 22 '19 at 05:16
177777), so you can easily see it's value. This indicated direct vs indirect addressing in one machine I used, and it also distinguishes signed from unsigned integers. (Personally, I recognize that 89ABCDEF has the same meaning in hex. shrug) – ikegami Aug 22 '19 at 20:36