The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Player_0 on April 14, 2007, 03:47:26 PM

Title: How do you use segment registers in masm? And is CONTEXT_EFlags defined?
Post by: Player_0 on April 14, 2007, 03:47:26 PM
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?
Title: Re: How do you use segment registers in masm? And is CONTEXT_EFlags defined?
Post by: Tedd on April 14, 2007, 05:18:11 PM
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.
Title: Re: How do you use segment registers in masm? And is CONTEXT_EFlags defined?
Post by: MichaelW on April 14, 2007, 08:11:12 PM
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.
Title: Re: How do you use segment registers in masm? And is CONTEXT_EFlags defined?
Post by: Player_0 on April 14, 2007, 09:28:56 PM
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."
Title: Re: How do you use segment registers in masm? And is CONTEXT_EFlags defined?
Post by: MichaelW on April 14, 2007, 09:45:15 PM
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
Title: Re: How do you use segment registers in masm? And is CONTEXT_EFlags defined?
Post by: Player_0 on April 15, 2007, 01:02:28 AM
Ah I didnt know ASSUME worked like that I never used it.
Thanks a lot!