Defining “variables” in assembly language

可紊 提交于 2019-12-01 20:56:58

Here's what you see in your "Watches" window:

a = 0 = 0x00 = 0x0000 = 0x00 0000 = 0x0000 0000

b = 167772160 = 16777216 * 10 = 0x1000000 * 0x0A = 0xA000000

c = 655360 = 65536 * 10 = 0x10000 * 0x0A = 0xA0000

d = 10 = 0x0A = 0x0000 000A

What does it mean? It means that your compiler did its job, but your debugger reads c and b as doublewords (4 bytes) instead of bytes.

When it reads in b, it reads its value 0x00, c´s value 0x0000, and d´s value 0x0A on the top, together making it 0xA000000.

Similar thing happens to c. a got lucky, as the next 4 bytes are zero, so the a is really zero.

However, this doesn't always have to be the case. Nothing says that there can't be any garbage after d, not to mention that variables equal to zero may appear in .bss (on a completely different memory location).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!