Address Alignment Design

How do you build address alignment just by looking at it?

On a 32-bit system, the address 0x12345670 means that it is 16 bytes (because of 0 at the end) to the right?

What about:

0x12345671 0x12345672 0x12345673

etc.?

Cheers, John

+3
source share
2 answers

Address A is n-aligned if A mod n is 0. Thus, 0x12345671 and 0x12345673 are aligned one at a time, and 0x12345672 is 2-aligned. 0x12345670, simultaneously, 1-aligned, 2-aligned, 4-aligned, 8-aligned and 16-aligned. You indicate only the highest degree of two (as lower forces imply).

+6
source

You are viewing hexadecimal digits:

  • 1, 3, 5, 7, 9, B, D, F: 1-aligned
  • 2, 6, A, E: 2-aligned
  • 4, B: 4-
  • 8: 8-aligned
  • 10, 30, 50, 70, 90, B0, D0, F0: 16-aligned
  • 20, 60, A0, E0; 32-aligned
  • 40, B0: 64-aligned
  • 80: 128-aligned
  • 00: 256-aligned or more...
+4

Source: https://habr.com/ru/post/1715239/


All Articles