Re: How to read/write an 'address' from a memory location......
- From: aeroboro221@xxxxxxxxxxxxxx
- Date: Mon, 22 Oct 2007 05:56:21 -0700
On Oct 20, 12:04 am, Hans-Bernhard Bröker <HBBroe...@xxxxxxxxxxx>
wrote:
aeroboro...@xxxxxxxxxxxxxx wrote:
I am trying to read an address from a memory location and then write
into that memory location.
Which "that" --- the one you read the address from, or the one the
address specifies?
unsigned long * mem_pointer = 0x93700020;
unsigned long mem_value = *mem_pointer;
The question is - How do i use the value at <i> mem_value </i> as an
address?
An address kept in a variable is called a pointer, in C programs. So
mem_value should be of a pointer type, rather than an integer.
Consequentially, mem_pointer should be a pointer-to-pointer-to-something
type, e.g.
some_type **mem_pointer = ...;
some_type *mem_value = *mem_pointer;
some_type the_actual_thing = *mem_value;
Basically, I want to do something like.
*(unsigned char *)mem_value = 10.
And what's keeping you from doing exactly that?
But this all hides a probably more important question: why do you think
you should be doing this?
My problem is: I have two processors exchanging data over a shared
section of memory. Now before processor 1 can write the data for
processor 2 (in the shared memory), processor 1 needs to tell
processor 2 where exactly it will be writing. Thats where i was coming
from - processor 1 basically needs to write an "address" into a
predefined location for processor 2 and that "address" will hold the
actual data for processor 2.
Thanks a lot for all your clarifications. I should try some of them
now!
Warm regards,
Rintu
.
- Follow-Ups:
- Re: How to read/write an 'address' from a memory location......
- From: Hans-Bernhard Bröker
- Re: How to read/write an 'address' from a memory location......
- From: John B
- Re: How to read/write an 'address' from a memory location......
- From: CBFalconer
- Re: How to read/write an 'address' from a memory location......
- References:
- How to read/write an 'address' from a memory location......
- From: aeroboro221
- Re: How to read/write an 'address' from a memory location......
- From: Hans-Bernhard Bröker
- How to read/write an 'address' from a memory location......
- Prev by Date: Re: Languages for embedded
- Next by Date: Re: Languages for embedded
- Previous by thread: Re: How to read/write an 'address' from a memory location......
- Next by thread: Re: How to read/write an 'address' from a memory location......
- Index(es):
Relevant Pages
|