By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,234 Members | 1,872 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,234 IT Pros & Developers. It's quick & easy.

Accessing memory locations in C programming

P: 3

I'm working on a 32-bit DSP processor.

I want to access memory location with address 0x3000h and clear all the memory locations from 0x3000h to 0x3300h to '0'.

Is the following an effective way to do it ?? If not, kindly be elaborate on your suggestions.

memset( (void*)0x3000, 0, 0x0300 );

thanks heaps..

Mar 20 '07 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 1,510
it depends on the processor and compiler. Generally you create a pointer to the type of variable in memory you wish to manipulate, then assign an address to that pointer and use it as one would any pointer by dereferencing it, e.g. a DOS program to clear the video RAM on a PC
Expand|Select|Wrap|Line Numbers
  1.    byte *video_start = (byte *) 0xB8000000L;     /* define start of PC video RAM */
  3.     byte *video_mem = video_start;        /* pointer initialised to video RAM */
  5.     /* clear 25 lines of 80 characters (character plus attribute byte) */
  6.     while (video_mem < video_start + 160 * 25)
  7.         {
  8.          *video_mem++ = ' ';                        /* set character to space */
  9.          *video_mem++ = (byte) attribute;                    /* set attribute */
  10.         }
have a look thru the compiler manuals and help pages - it should tell you how to do this type of operation on your system
Mar 20 '07 #2

P: 2,476
if the program runs under DOS then it uses 16 bit runtime env.......

what u r doing .... that does not depend on processor env
Mar 20 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.