Accessing Segment Registers MASM

a 夏天 提交于 2019-12-01 23:42:06

问题


I'm trying to query the value located in the Process Enviornment Block, pointed to by the FS segment register. Attempting to compile code with the fs:[0] segment included results in an error (error A2108: use of register assumed to ERROR).

How do you query the segment registers?!

Thanks


回答1:


MASM by default assumes that any access to the segment registers is an error (which usually it is). You need to redefine the assumptions for the FS register using ASSUME FS:NOTHING. You can place this directive at the top of your file, OR you could "reassume" the FS register temporarily. Example:

ASSUME FS:NOTHING
MOV EAX, FS:[0]
ASSUME FS:ERROR

This way you turn off the error checking only for this single instruction. The ASSUME directives only inform the assembler what to do, they don't cause any code to be emitted.




回答2:


According to the MSDN documentation for error A2108, you need to add an assume directive to your code.

ASSUME NOTHING at the top of your file should remove register error checking.

I presume this is because for most code, using the segment registers results in incorrect behavior.



来源:https://stackoverflow.com/questions/1074058/accessing-segment-registers-masm

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