views:

56

answers:

2

Dear All,

This symbol used in MASM32:

@CodeSize Returns an integer representing the default code distance.

I'm trying to understand what 'default code distance' means?

Tony

A: 

Very probably the maximum distance (in bytes, in memory) between the two most distant pieces of code. This might influence how jumps are generated, since there can be different instructions capable of different jump lengths. A shorter jump can be encoded with a shorter (smaller, often faster) instruction.

This page mentions what integer values one can expect:

0 for TINY, SMALL, COMPACT, and FLAT models, and 1 for MEDIUM, LARGE, and HUGE models (numeric equate).

unwind
+2  A: 

The default code distance is either NEAR or FAR.

@CodeSize can take two values, either 0 or 1, which determines if jumps, calls etc. are in NEAR or FAR distance.

If you are using the TINY, SMALL, COMPACT or FLAT memory model, all jumps etc. are NEAR, and @CodeSize == 0. If you are using the HUGE, LARGE, MEDIUM memory model, als jumps etc. are FAR and @CodeSize == 1.

drhirsch
What exactly is meant with NEAR and FAR? Is it that they are in the current segment or outside the current segment?
Tony
Yes, but for the protected mode it is much more complicated, as there are selectors involved. Basically NEAR and FAR are different adressing modes, with an additional 16-bit component for FAR jumps, which may have very different meanings depending on the operation mode. The exact specification is in http://www.intel.com/Assets/PDF/manual/253666.pdf. Look under "JMP FAR".
drhirsch