Hex vs. decimal representation of numbers in registers and operands

1

I have had trouble with conceptually understanding assembly language. And I would like to clarify if I am on the right track.

For example, lets say the register eax contains the hex value 0x000000FF and the instruction is add eax, 44d. All I essentially would be doing is adding 44 to 255, which is what FF is. And the result would be 0x0000012B matching the format of what was already in the eax register. I would like clarification on this thanks.

assembly
x86
asked on Stack Overflow Dec 13, 2016 by Nate B • edited Dec 14, 2016 by Peter Cordes

1 Answer

1

The numbers has no "numeral system" at all. They have only value.

The numeral system (hexadecimal, decimal, octal, binary, etc) is only a writing system. It has meaning only if the number has to be written on some information carrier - sheet of paper, computer screen, memory cell, etc.

Changing the numeral system, does not change the value of the number.

So, you can write the number in different numeral systems and it will have the same value, regardless that it seems to be different. You only need to read it differently.

In assembly language, the hexadecimal system is preferred because it allows very easy (mentally) converting to and from binary (the system CPU use to write numbers in the memory). That is why most debuggers will display the numbers in hex.

answered on Stack Overflow Dec 16, 2016 by johnfound

User contributions licensed under CC BY-SA 3.0