views:

295

answers:

2

Hello! 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  A: 

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.

Michael
+1  A: 

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.

stormsoul