Aargh! Stop using those silly CR line delimiters and use LF line
delimiters instead! This post appears as follows on tin:
Hello -^M^MI'm trying simple read/write operations to memory...
While I'm sure you wished it to appear like so:
Hello -
I'm trying simple read/write operations to memory...
: Hello -
I'm trying simple read/write operations to memory and need some help
: with getting started. I've tried this:
for(x = 0x1d200000; x < 0x1d201ffc;
: x++)
printf("Contents of address: %x are %x .\n",x,*x);
I hope you've declared x as a pointer (like unsigned char *) and not as
an int or long. Anyway a better solution is to compare an offset from
the pointer instead of the pointer:
unsigned char *x;
unsigned long i;
x=(unsigned char *)0x1d200000;
for (i=0; i<0x1ffc; i++)
printf("Contents of address: %x are %x .\n", 0x1d200000+i, *(x+i));
and
&x =
: 0x1d200000;
&pointer2 = 0x1d201ffc;
...
This is simply wrong. Never try to set the address of a variable
yourself. For one thing, it's a compiler error (addresses aren't
lvalues), for another, it doesn't make sense. To set a pointer to
an absolute address try this:
unsigned char *x;
x=(unsigned char *)0x1d200000;
while(x != pointer2)
{
x++;
: printf("Contents of address: %x are %x .\n",x,*x);
}
what am I doing
: wrong, and what are some tips I can use? thanks.
Dan
What you are doing wrong is that you are happily mixing up addresses,
pointers, and scalar values. If you follow my advice on this post,
this code should work on most common platforms (like Windows, Unix,
Amiga...) but on systems with memory protection (like Unix) you will
get a segmentation fault if you try to read the contents of memory
that doesn't belong to you. Also note that not all systems allow
assigning absolute addresses to pointers in the first place.
--
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #80 D+ ADA N+++ |
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"Stronger, no. More seductive, cunning, crunchier the Dark Side is."
- Mika P. Nieminen