Jrdman said:
i wanna access the memory address at 0x00(first segment) and then
printf a range of memory from the first segment to a specific address
something is wrong with this idea ?if this ,is possible please help
me?
What you are asking to do is system-specific.
Most of the systems I use don't have segments at all; the other systems
I use that do have segments pretty much ignore the existance of segments
and use linear virtual address ranges in practice. So what you
are asking for is impossible on many systems and irrelevant on a bunch
more.
As you are wanting to do something that isn't possible at all on
many systems that run C, if you are able to implement it at all
on the systems of interest to you, you have to use non-portable methods
to accomplish it.
On C systems that use a linear virtual address space, you can
often (but it isn't promised to work) look at offsets in your virtual
address space by converting the offset from an integral type to a pointer.
For example,
unsigned char *ptr = (char *)0x000003fc;
unsigned char c = *ptr;
C doesn't define what this means: C says that the implementation
can assign any meaning it wants to the conversion shown in the first line.
Actually attempting to access the memory you've constructed a pointer
to might do nearly anything, including possibly hang your system. (And
I don't mean that lightly: just *reading* from memory addresses can
trigger nasty hardware behaviour.)
Because C doesn't define the conversion, the memory address actually
examined might have no obvious relationship at all to the constant
0x000003fc -- you may have to dig deep into your system documentation
to find out which address constant you need to use to access particular
memory locations.
Even on systems that have segments at all, there is no common
idiomatic way of storing particular values in segment base registers.
You might have to drop in some inline assembler, if your C happens
to have an inline assembler extension (inline assembler is not
part of C.)