Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - segmentvalue() return the segment address of an object http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 segmentvalue()      Return the segment address of an object
------------------------------------------------------------------------------
 Declaration
   memory.hdr

 Syntax
   func uint segmentvalue extern
   param untyped xObject

 Arguments
   xObject is a memory object.

 Return
   The segment address of the passed object.

 Description
   The segmentvalue() function returns the segment part of the memory
   address of the specified object.

 Example
   #define EXAMPLE_MEMORY
   #include example.hdr

   // Test if various objects are located in the same segment
   
   dbfdef sTest1 public
   enddef
   
   dbfdef sTest2 static
   enddef
   
   vardef public
      char cPublic
   enddef
   
   vardef static
      char cStatic
   enddef
   
   vardef far
      char cFar
   enddef
   
   vardef sfar
      char cSFar
   enddef
   
   proc DispSeg
   param untyped xObject
   // Display segment address of a memory object
   ? right( dechex( segmentvalue( xObject ) ), 4 )
   endproc
   
   proc Test_segmentvalue
   vardef
      char cLocal
      uint uNumber
   enddef
   DispSeg( sTest1 )               // variables in data segment
   DispSeg( sTest2 )
   DispSeg( cPublic )
   DispSeg( cStatic )
   DispSeg( __syscolor[] )
   ?
   DispSeg( cFar )                 // variables in far data segment
   DispSeg( cSFar )
   ?
   DispSeg( cLocal )               // variables in far data segment
   DispSeg( uNumber )
   ?
   DispSeg( Test_segmentvalue )    // function in this module's code segment
   ?
   DispSeg( segmentvalue )         // function in another code segment
   endproc

   proc main
   Test_segmentvalue()
   endproc

See Also: & offsetvalue()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson