PDA

View Full Version : DAT declaration



DarrenY
09-17-2007, 05:17 PM
I have a simple problem that's driving me mad as I can't get it to work!

In my main module I (want to) declare a DAT block of bytes, that I get the address of via F8

I then use this address within a 'MemoryMap.spin' file:




CON BaseAddr = $54 ' Base Memory location - should be address of DataBlock in main module

CON
Var1 = 0
Var2 = 4
Var3 = 8
Var4 = 12
...
LastVar = 192




I then include the MemoryMap.spin object in all the spin files that need to access the memory block.
The main files memory block can then be read/written from any module using the following:




readvar1 := long[constant(memmap#BaseAddr + memmap#Var1)]
long[memmap#BaseAddr + memmap#Var2] := writevar2




(where memmap is OBJ memmap : "MemoryMap")


Trouble is, I am having trouble getting the main module to declare an array of bytes in the DAT block:




DAT
DataBlock byte memmap#LastVar ' this is the last (i.e. size of) var in the global memory map




Is this the correct syntax?


Cheers all.

Mike Green
09-17-2007, 09:27 PM
The syntax you used simply declares one byte whose value is that of memmap#LastVar. There's no documented provision for declaring arrays of data in a DAT section. I seem to remember a previous post mentioning an undocumented feature that you could try:


DAT
DataBlock byte 0[ memmap#LastVar ]



Someone else may remember more about this than I can.

DarrenY
09-17-2007, 09:41 PM
worked first time! Thanks!!

I'd be interested to hear exactly what it's doing though.......

Fred Hawkins
09-17-2007, 09:57 PM
Mike Green said...
The syntax you used simply declares one byte whose value is that of memmap#LastVar. There's no documented provision for declaring arrays of data in a DAT section. I seem to remember a previous post mentioning an undocumented feature that you could try:


DAT
DataBlock byte 0[ memmap#LastVar ]



Someone else may remember more about this than I can.


is this it? http://forums.parallax.com/showthread.php?p=659730

also this example: http://forums.parallax.com/showthread.php?p=586819

finally, about aliasing: http://forums.parallax.com/showthread.php?p=659730

I am starting to think we need manual 1.02

Post Edited (Fred Hawkins) : 9/17/2007 3:14:20 PM GMT

deSilva
09-18-2007, 12:29 AM
It is well described in the Supplement/Errata http://forums.parallax.com/images/smilies/smile.gif
www.parallax.com/dl/docs/prod/prop/PMv1.0Supplement-v1.1.pdf (http://www.parallax.com/dl/docs/prod/prop/PMv1.0Supplement-v1.1.pdf)