[En-Nut-Discussion] Placing and array at some specific place inmemory

Michael Jones Michael.e.Jones at web.de
Wed Oct 25 16:02:42 CEST 2006


Try e.g.:

	char (*pScreen)[80];

	pScreen = (char (*)[80]) 0x8000;
or
 	pScreen = (char (*)[80]) NutHeapAlloc(25*80);

	pScreen[23][40] = 'A';


The expression: char (*pScreen)[80]; defines one pointer (that why it's in
()'s) to an arrow of 80 char which in C can always be indexed, thus the
[y][x].

Also, if you can help it and you haven't got e.g. memory or external devices
not assigned to the system heap, don't use absolute addressing but use
NutHeapAlloc etc. instead. That would be asking for trouble...

Regards,
Michael



-----Original Message-----
From: en-nut-discussion-bounces at egnite.de
[mailto:en-nut-discussion-bounces at egnite.de] On Behalf Of Uwe Bonnes
Sent: Saturday, October 21, 2006 11:20 PM
To: en-nut-discussion at egnite.de
Subject: [En-Nut-Discussion] Placing and array at some specific place
inmemory

Hallo,

is it possible to place an array at some specific place in memory?

I can do something like
volatile unsigned char *id_mem= (volatile unsigned char *)0x3200; 
but how can I place something like
unsigned char hid[OWI_LOCAL+1][9];
at e.g. 0x3300?

Accessing hid[device][byte] seems much clearer to me than accessing
*(hid + device * N_BYTES + byte). Any other ideas or coding styles?

Thanks
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion





More information about the En-Nut-Discussion mailing list