How do you use segment registers in masm? And is CONTEXT_EFlags defined?

Started by Player_0, April 14, 2007, 03:47:26 PM

Previous topic - Next topic

Player_0

Is setting the memory model to tiny the only way to work with registers like FS?
I find code that uses symbols that it doesnt define as variables such as CONTEXT_Dr0, ER_ExceptionCode, CONTEXT_Eip, CONTEXT_EFlags which obviously have to do with the context structure. Is there anyway to use these symbols in masm instead of going to the addresses manually?

Tedd

They must be defined somewhere in one of the included files - if you can get the details then you can easily define readable equates yourself and then use those in-place.

Or do you mean using the fs register itself? Which I wouldn't recommend, but you can do "assume fs:nothing" to stop warnings about it being used.
No snowflake in an avalanche feels responsible.

MichaelW

If you are working with exception handling under Windows, the tiny memory model is totally unrelated. Try this page for information:

http://www.jorgon.freeserve.co.uk/Except/Except.htm

If you are working with a 16-bit DOS program you can use FS and GS as you would ES, independent of the memory model, but you must first specify a .386 or higher processor directive.
eschew obfuscation

Player_0

When I use the FS register for playing with SEH I get errors with FLAT model but no errors with TINY model.

I found this site http://www.powerbasic.com/support/help/pbcc/flat_memory_model.htm which says "All segment registers are automatically set to the same value with the flat memory model.  This means that segment / offset addressing must NOT be used in 32-bit programs that run in 32-bit Windows operating systems."

MichaelW

Which error you are getting is significant. With the FLAT model, by default, if you try to use FS you should get:

error A2108: use of register assumed to ERROR

Meaning that the default is: ASSUME fs:ERROR

Tedd already indicated how to correct the problem: ASSUME fs:NOTHING
eschew obfuscation

Player_0

Ah I didnt know ASSUME worked like that I never used it.
Thanks a lot!