Symbol name conflicts with new register names in new NASM versions?

旧城冷巷雨未停 提交于 2019-12-01 03:34:33

NASM lets you prefix a symbol with a dollar sign $ so that it's interpreted as symbol rather than register or other reserved word. From the NASM documentation:

3.1 Layout of a NASM Source Line

[...] An identifier may also be prefixed with a $ to indicate that it is intended to be read as an identifier and not a reserved word; thus, if some other module you are linking with defines a symbol called eax, you can refer to $eax in NASM code to distinguish the symbol from the register. [...]

MASM is normally only used in environments where C compilers prefix identifiers with underscores _, so this isn't as big of an issue with that assembler. However it does have a solution this problem, but it's basically the opposite of NASM's. You can use the OPTION NOKEYWORD directive to disable reserved words of your choice. For example you can use OPTION NOKEYWORD:<eax> so that you can use a symbol named eax. Of course that prevents you from using the register named EAX, so it's not as general solution as NASM's.

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