User Tools

Site Tools


x86_memory_aliasing

This is an old revision of the document!


x86 Memory Aliasing

In short: Aliasing is the way an x86 CPU maps an assembler address to a physical address.

You may have seen stuff like “segment:offset” in regard to addressing. For a real location this could be “0000:7C00”. This means: Segment 0000, offset 7C00, and this is where your computer starts when it boots.
But this is not an absolute address. The segment is shifted four bits to the left and added to the offset. So the absolute address for “0000:7C00” is “07C00”. Now, consider this address “07C0:0000”. So segment “07C0” and offset zero. You shift the segment four to the left making “7C00” and then add the offset of zero. The result is “7C00” which is the same as “07C00”.
Result: “0000:7C00” is the same physical address as “07C0:0000”.
You will see this throughout articles you find on the subject, and they will mix these up. Learn to read these as their proper physical addresses.
You will need this when your code bugs out, because your code may execute at segment “0000” and your data may be read/written at segment “07C0”. Effectively making your code work some times and bug out at other times. If in doubt, make sure you're at the correct segment. This because most assembler instructions will not update the segment, but assume it's correct. So if the segment is set to “07C0” and you try to read offset “7C58”, you will get a weird result. “07C0:7C58” (07C0«4+7C58=08418) is obviously not the same as “0000:7C58” (07C58).

Just be aware of this functionality of the x86 processor when things does not work as you thought it would.

x86_memory_aliasing.1488483762.txt.gz · Last modified: 2017/03/02 19:42 by admin