Hi I have an array of unsigned chars, like:
MyArray[2048] = {0x00};
For memory-mapping purposes I need to store this array at a specific address
(0xFFFF1199)
How do I declare this?
I cant't do MyArray[2048] = {0x00} @ 0xFFFF1199 :-(
I am using the gnu compiler.
Best Regards
Don 24 16337
Don <no**@spam.dk > scribbled the following: Hi I have an array of unsigned chars, like: MyArray[2048] = {0x00};
For memory-mapping purposes I need to store this array at a specific address (0xFFFF1199)
How do I declare this?
You can't. Not under ISO standard C. On some implementations , you can't
declare it at all.
I cant't do MyArray[2048] = {0x00} @ 0xFFFF1199 :-(
No, you can't.
I am using the gnu compiler.
It depends on more than your compiler. Some operating systems don't
allow specific addresses at all, due to security reasons. What happens
if some other process is already using that memory?
Please ask in gnu.gcc.help or a system-specific newsgroup.
--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"Don" <no**@spam.dk > wrote:
# Hi I have an array of unsigned chars, like:
# MyArray[2048] = {0x00};
If it _has_ to be an array instead of (unsigned char*), many linkers allow you to
specify the address of extern objects. You might try checking what your linker
permits.
--
Derk Gwen http://derkgwen.250free.com/html/index.html
You face forward, or you face the possibility of shock and damage.
Derk Gwen <de******@hotpo p.com> wrote: "Don" <no**@spam.dk > wrote: # Hi I have an array of unsigned chars, like: # MyArray[2048] = {0x00};
If it _has_ to be an array instead of (unsigned char*), many linkers allow you to specify the address of extern objects. You might try checking what your linker permits.
You can do it without linker magic also:
#define MyArray (*(volatile unsigned char (*)[2048])(0xdeadbeef))
- Kevin.
On Thu, 25 Sep 2003, Don wrote: Hi I have an array of unsigned chars, like: MyArray[2048] = {0x00};
For memory-mapping purposes I need to store this array at a specific address (0xFFFF1199)
How do I declare this?
I cant't do MyArray[2048] = {0x00} @ 0xFFFF1199 :-(
I am using the gnu compiler.
If possible, just use:
unsigned char *MyArray = (unsigned char *)0xFFFF1199;
and then use MyArray as if you declared it as an array. The only
difference is that sizeof(MyArray) will not return 2048.
If you have to have it as an array then check with a newsgroup that deals
with your compiler. You can sometimes define a section of data to a linker
section name (.text, .bss. data, etc.) and then instruct the linker to put
that section at a specific memory location. This is highly dependent on
your linker and completely off topic for comp.lang.c.
--
darrell at cs dot toronto dot edu
or
main(){int j=1234;char t[]=":@abcdefghijk lmnopqrstuvwxyz .\n",*i=
"iqgbgxmdbjlgdv .lksrqek.n";cha r *strchr(const char *,int);while(
*i){j+=strchr(t ,*i++)-t;j%=sizeof t-1;putchar(t[j]);} return 0;}
On Thu, 25 Sep 2003 10:02:07 GMT, in comp.lang.c , Kevin Easton
<kevin@-nospam-pcug.org.au> wrote: Derk Gwen <de******@hotpo p.com> wrote: "Don" <no**@spam.dk > wrote: # Hi I have an array of unsigned chars, like: # MyArray[2048] = {0x00};
If it _has_ to be an array instead of (unsigned char*), many linkers allow you to specify the address of extern objects. You might try checking what your linker permits.
You can do it without linker magic also:
#define MyArray (*(volatile unsigned char (*)[2048])(0xdeadbeef))
When I tried this on my DS9K, it said "moo" and printed out a recipe
for making cow from hamburger.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>
>> #define MyArray (*(volatile unsigned char (*)[2048])(0xdeadbeef)) When I tried this on my DS9K, it said "moo" and printed out a recipe for making cow from hamburger.
liar
Joona I Palaste <pa*****@cc.hel sinki.fi> writes: Don <no**@spam.dk > scribbled the following: Hi I have an array of unsigned chars, like: MyArray[2048] = {0x00};
For memory-mapping purposes I need to store this array at a specific address (0xFFFF1199)
How do I declare this?
You can't. Not under ISO standard C. On some implementations , you can't declare it at all.
Of course you can.
memcpy((void*)0 xFFFF1199, MyArray, sizeof MyArray);
Now, whether or not this does what you want is
implementation-defined, but you certainly can do it, if it's
doable. The Standard specifically says so.
-Micah
Martijn wrote: #define MyArray (*(volatile unsigned char (*)[2048])(0xdeadbeef))
When I tried this on my DS9K, it said "moo" and printed out a recipe for making cow from hamburger.
liar
It would be just like the DS9000 to print out a bogus recipe. That's the
kind of thing it likes to do.
Brian Rodenborn
Default User <fi********@com pany.com> writes: Martijn wrote:> #define MyArray (*(volatile unsigned char (*)[2048])(0xdeadbeef))
When I tried this on my DS9K, it said "moo" and printed out a recipe for making cow from hamburger.
liar
It would be just like the DS9000 to print out a bogus recipe. That's the kind of thing it likes to do.
Should be thankful it didn't launch nukes http://dspace.dial.pipex.com/town/green/gfd34/art/
-Micah This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dan |
last post by:
hello,
I would to know if it is possible to delete an instance in an array, The
following does not allow me to do a delete.
I am trying to find and delete the duplicate in an array, thanks
for ( j =0; j<MAX ; j++)
{
for ( i =0; i<MAX ; i++)
|
by: Timo |
last post by:
I am trying to get address of myStruct to a string array texts.
I am using M$ Visual C++ 6.0 (this is not OS specific question, though,
this code should also work on 16 bit embedded compiler ;)).
This is my code:
typedef struct
{
const unsigned short a;
const unsigned long b;
|
by: David Mathog |
last post by:
If this:
int i,sum;
int *array;
for(sum=0, i=0; i<len; i++){
sum += array;
}
is converted to this (never mind why for the moment):
|
by: Jens Mittag |
last post by:
Hi!
In my code, I have an array of a structure, which I want to save to a
binary file. When the array is just created, everything works fine, but
when I change contents of the array, saving results in a file, which
doesn't hold the information of the changed array anymore. I dont know why.
Here is the code:
/*
|
by: Alexei A. Frounze |
last post by:
Hi all,
I have a question regarding the gcc behavior (gcc version 3.3.4).
On the following test program it emits a warning:
#include <stdio.h>
int aInt2 = {0,1,2,4,9,16};
int aInt3 = {0,1,2,4,9};
| |
by: anonymous |
last post by:
I have couple of questions related to array addresses. As they belong
to the same block, I
am putting them here in one single post. I hope nobody minds:
char array;
int address;
Questions 1:
Why cannot I do the following:
|
by: Tomás |
last post by:
Some programmers treat arrays just like pointers (and some even think that
they're exactly equivalent). I'm going to demonstrate the differences.
Firstly, let's assume that we're working on a platform which has the
following properties:
1) char's are 8-Bit. ( "char" is synomonous with "byte" ).
2) int's are 32-Bit. ( sizeof(int) == 4 ).
3) Pointers are 64-Bit. ( sizeof(int*) == 8 ).
|
by: gcary |
last post by:
I am having trouble figuring out how to declare a pointer to an array
of structures and initializing the pointer with a value. I've looked
at older posts in this group, and tried a solution that looked
sensible, but it didn't work right. Here is a simple example of what
I'm trying to accomplish:
// I have a hardware peripheral that I'm trying to access
// that has two ports. Each port has 10 sequential
// registers. Create a...
|
by: Abhi |
last post by:
I wrote a function foo(int arr) and its prototype
is declared as foo(int arr); I modify the values of the array in the
function and the values are getting modified in the main array which
is passed also. I understand that this way of passing the array is by
value and if the prototype is declared as foo(int *), it is by
reference in which case the value if modified in the function will get
reflected in the main function as well. I dont...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |