"red floyd" <> wrote in message
news:13Lef.16952$q%. m...
> Jonathan Mcdougall wrote:
> > Ivan wrote:
> >
> >>Hi
> >>
> >>how can I access the contents of a memoy location say at address 0x3FF
in C?
> >>
> >>I tried this but didn't work
> >>
> >>unsigned int *wVal = 0x3FF;
> >>x = *wVal;
> >
> >
> > That's undefined behavior in standard C++, but it may work on your
> > platform. You have to cast it explicitly because 0x3FF is an int and
> > ints cannot be implicitly converted to pointers.
> >
> > unsigned int *wVal = reinterpret_cast<unsigned int*>(0x3FF);
> >
>
> What, exactly, is the OP trying to accomplish? Is he trying to tweak an
> interrupt vector or memory mapped I/O?
>
> Unless you're on a system where there's no memory management, there's no
> guarantee that 0x3ff will be a valid memory address in your address
> space. If you're attempting to access a memory-mapped I/O port, or some
> system structure, you're toast, under a virtual memory system.
>
> If you're writing an OS kernel or run-time executive, or you're in an
> environment where there's no MMU, then that's an entirely different
> kettle of fish.
>
it is an embedded system, I thought there was a standard way of doing it,
well I suppose I'll have to contact them to know how to do it.
thanks you all
|