Why do computer use Hex Number System at assembly language? Why don't they use any other number system like binary, octal, decimal? What thing forced computer designer to use hex system at assembly? Why it looked so beneficial to them?
4 Answers
Computers don't use the hexadecimal number system for assembly language. Assembly language, or rather machine code, uses base 256 (typically): instructions are encoded in units of bytes. When displaying machine code, it is customary to use octal or hexadecimal. The reason is that in many cases, the byte is further subdivided into bitstrings, and identifying these bitstrings is easier when using a base which is a power of 2. Hexdecimal is particularly compact since each byte can be encoded using exactly two hexadecimal digits.
-
$\begingroup$ +1 exactly it's because of the simplicity of conversion to binary, with practice you can "see bits" while coding in hex (as a reference I've even asked why it's fundamentally harder to convert bin<=>decimal than bin<=>hex(among others), cs.stackexchange.com/questions/21736/…) $\endgroup$ Jun 16, 2014 at 19:51
The simplest reason is that, the computer does not see this, it only sees the binary. This really just aids the programer. Binary is a mess to look at, octal does not usually work since an octal number is three bits and historically computers have been using 16,32,64 bit instruction sets, none of which are divisible by 3, leaving hex as the best choice.
Note that using octal vs hexadecimal is mostly a matter of programming and documentation, rather than the computer itself. (Apart from, say, a front panel display with hex digits.)
Octal was popular with programmers until about the 1970s, when hexadecimal pretty much took over. Octal has the advantages of using normal digits (no letters) and being simpler to work with (e.g. addition), although it's slightly less dense than hexadecimal.
The huge advantage of hexadecimal is when you're working with a 16-bit (or larger) machine, since the bytes break into hexadecimal cleanly. In hexadecimal, ASCII "A" is 41 and "B" is 42, so a word with "AB" is 4142. Reversing the bytes gives 4241. Octal, on the other hand, is a huge pain. "A" is 101 and "B" is 102, but word "AB" is not 101102 but inconveniently 40502 and "BA" is 41101 - it's hard to pull the bytes out of the word. Thus, hexadecimal rapidly became popular as 16- and 32-bit machines became common. (I'm working with a 16-bit Xerox Alto (1973) that used octal for everything, and it's a big pain.)
One interesting historical note is that Intel's processors from the 8008 through x86 have an instruction set designed around octal, but it's entirely documented in hexadecimal. If you look at opcodes in octal, the instruction structure becomes clearly visible (details).
Another historical note is Unix and C show strong octal influence, for example the od octal dump command, the use of octal in the tr command, C octal escape sequences, octal file permissions, etc.
Hexidecimal (TM copyright IBM) is a notation. It incorporates a familiar numeric system, the Binary Coded Decimal (BCD) of 10 symbols 0-9 in a 4 bit representation system, the remaining 6 values of the 16 possible combinations are represented by a,b,c,d,e,f or A,B,C,D,E,f respectively. In this fashion a 'nibble' of 4 bits can conviently represent all the possible values in a simple notation.