effect of free()

Scott Amspoker scott at bbxsda.UUCP
Fri Sep 22 03:03:12 AEST 1989


In article <990 at kim.misemi> kim at kim.misemi (Kim Letkeman) writes:
>
>Can you tell me how you would go about causing an 80286 to trap on
>load of a "bad" value in the ES That's? This register is internal to
>the CPU and I doubt that there are any values that would cause a trap
>to be raised simply by loading them.

When you load a segment register on an 80286/80386 in *protected* mode
the CPU actually goes into an in-memory table an load a segment
descriptor in to an on-chip cache so that subsequent address translation
is reasonably fast.  If the segment register is loaded with a value
that does not have an associated segment descriptor then a trap
occurs.  This normally doesn't cause a problem.  ES is not
preserved across CALLs.  C compilers on the 80286 are not inclined
to load ES just to perform a pointer move or compare because

   1) segment register loads are expensive
   2) there is no segment register compare instruction

In *real* mode (MS-DOS) there is no possibility of a bad address trap.

-- 
Scott Amspoker
Basis International, Albuquerque, NM
(505) 345-5232



More information about the Comp.lang.c mailing list