The Layout of Data in Memory

Now I have a question for you. After we execute the assembly language statement mov ax,[1000] to load the value of i into ax, what's in register ax? Of course; the answer is the value of i, but what is that value? The first byte of i, at location 1000, has the value 41 hexadecimal (abbreviated 41h), and the second byte, at location 1001, has the value 42h. But the value of i is 2 bytes long; is it 4142h or 4241h? These are clearly not the same!

That was a trick question; there's no way for you to deduce the answer with only the information I've given you so far. The answer happens to be 4241h, because that's the way Intel decided to do it; that is, the low part of the value is stored in the byte of RAM where the variable ...

Get C++: A Dialog Programming with the C++ Standard Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.