hi,
i'm not sure how to create 3-dimensional arrays of different types. can someone perhaps paste a code snippet or something? the things that are important are how to declare such a structure, how to fill it in .data and .data? section, and how to fill them during runtime.
this are the things i want to do:

there should be an array of coordinates (x and y). and this coordinates depend on a layer number. for example:

layer1: (x,y)-coordinates1, (x,y)-coordinates2, ....
layer2: (x,y)-coordinates1, (x,y)-coordinates2, ....
layer3: ..................................................................

you could also write that like this:

layer1: - coordinates x,y 1
layer1: - coordinates x,y 2
layer1: - coordinates x,y n

layer2: -coordinates x,y 1
layer2: -coordinates x,y n

and so on.
i just use so many examples to make totally clear what i mean.

Hope you understand.

NOP-erator
Posted on 2001-10-01 05:59:38 by NOP-erator
NOP-erator,

It will depend on the scale of what you are doing, if the arrays are only small, you could create them in the .DATA or .DATA? sections but if they are more than a few K in size, I would not recommend doing that as you file will end up too large.

If you allocate memory for the array with GlobalAlloc() or similar, you can write the data in a couple of different ways, for example if you had 3 x 10 item arrays, you could arrange the data as,
111222333444555666777888999000
or
123456789012345678901234567890

It really depends on how you want to write the array access, start address in a register + index * scale(4 for DWORD) + displacement.

mov eax, ; dimension 1
mov eax, ; dimension 2
mov eax, ; dimension 3

This will give you any one of the first 3 elements.

You add the offset to ECX to access the higher values.

The alternative in the second form is to calculate the offsets of the second and third positions and then just read the number at that position + the offset you need for the particular item.

Regards,

hutch@pbq.com.au
Posted on 2001-10-01 06:47:35 by hutch--
thanks hutch. here is some additional information to my problem:
it'll be an array of 60*3. the 3 consists of:

1 DWORD
2 REAL4

so, in a total 60*3*4 bytes, right? would you recommend to use GlobalAlloc then? would you please explain a bit more in detail how to fill the memory then? by the way: i'll need about 3 of this arrays then, and i need to fill them before runtime.

what would you do? notice that i'll also use fpu commands with the 2 REAL4.

thanks,
NOP-erator
Posted on 2001-10-01 07:25:33 by NOP-erator
hutch-- or anybody else,

please answer my question. just wrote that, so that my post doesn't move into the nirvana of uncomplete posts. sorry for that.

thank you!

NOP-erator
Posted on 2001-10-02 03:55:23 by NOP-erator
I'd use a struct:

ValStrct Struct
a dd ?
b dd ?
c dd ?
ValSrtct Ends

Then you can either allocate memory like this

.data?
Strct1 ValStrct 60 dup ({?})

or

.data
Strct1 ValStrct {6,78.0,67.65},{56,34.0,87.5}, ...

Alternativly do it dynamically

.data?
pStrct1 dd ?

.code
mov eax,60
imul eax,sizeof(ValStrct)
invoke GlobalAlloc,GPTR,eax ; Hope thats the right order
mov pStrct1,eax

The easist way to access them through a loop would be

mov edx,pStrct1; or lea edx,Strct1
mov ecx,60*sizeof(ValStrct)
lp: fild .ValStrct.a
fadd .ValStrct.b
fmul .ValStrct.c
fstp st
sub ecx,sizeof(ValStrct)
jnz lp

To access them by valiable the you'll have to multiply

mov ecx,10
imul ecx,sizeof(ValStrct)

fld .Valstrct.a
fstp st

Hope that helps.
Posted on 2001-10-02 05:49:46 by Eóin
Just to clarify something...


It will depend on the scale of what you are doing, if the arrays are only small, you could create them in the .DATA or .DATA? sections but if they are more than a few K in size, I would not recommend doing that as you file will end up too large.


Using .data means increased file size, but .data? doesn't.
Posted on 2001-10-02 10:38:18 by f0dder
ok, thanks,
NOP-erator
Posted on 2001-10-02 12:31:00 by NOP-erator