Shop OBEX P1 Docs P2 Docs Learn Events
Addresses and Hex — Parallax Forums

Addresses and Hex

Vega256Vega256 Posts: 197
edited 2012-07-18 07:31 in General Discussion
Hey guys,

Usually, anywhere I see a reference to a location in memory, whether it be in assembly language code or even in a Windows memory error report, the location is represented in hex, why?

I understand that every hexadecimal digit represent a nybble in binary, but to me, that doesn't make hex easier to work with; as with, for example, indexing. If I started at location $1000 and I wanted to go 141 bytes over, I don't automatically think "Well, that's $8D over...". It just doesn't come natural.

Comments

  • Heater.Heater. Posts: 21,230
    edited 2012-07-18 06:30
    Hex is the way programmers think. From instruction op codes to addresses to data content. Working in hex is a natural in binary systems.

    For example the Prop's HUB RAM size is 32Kb. That is 32768 decimal. or 8000 hexadecimal, easy ha.
    When you are dealing with memory maps or paged memory the sizes of different areas are nearly always a multiple of 2. so binary or hex notation is natural. As soon as yo see a hex address you know if it fits within the page or how many pages it takes with no mental conversion from decimal.

    Also hex comes naturally for the max values you can store in bytes, words, longs etc,

    Luckily octal is not so prevalent now a days:)
  • Vega256Vega256 Posts: 197
    edited 2012-07-18 06:33
    Heater. wrote: »
    Luckily octal is not so prevalent now a days:)
    Octal is easier for me than hex. Figures...
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-07-18 06:41
    Heater. wrote: »
    Luckily octal is not so prevalent now a days:)
    Yet the od (octal dump) utility is still available on Linux, and its default mode is octal. And make sure you don't preceed a decimal number with a zero in C, such as 01234. You'll end up with octal instead of decimal.
  • Heater.Heater. Posts: 21,230
    edited 2012-07-18 07:31
    Dave Hein,

    ...make sure you don't preceed a decimal number with a zero in C,

    Yep, that's really annoying.

    Crazy thing is they carried that idea over into Javascript. How often do WEB developers think in octal, or hex for that mater?
Sign In or Register to comment.