News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

problem with array

Started by Dav92, December 05, 2010, 11:28:04 AM

Previous topic - Next topic

Dav92

Hi,

Here's the array that makes problems:

DllChaOwn:dword[6]:=[&DllChaV[0],&DllChaV[4],&DllChaV[8],&DllChaV[12],&DllChaV[16],&DllChaV[20]];
DllChaV:dword[6]:=[49990,$80,$80,$80,$80,$80];


The problem now is, that the first array is initialized with the base address of the second array after compiling, always.

Does anyone know how to solve that problem?

jj2007

> DllChaOwn:dword[6]:=[&DllChaV[0]
Does the & mean a pointer to DllChaV[0]? What happens if you remove the &?

Dav92

Yes, the & means a pointer and without it, the program can't be compiled.

I've currently found a workaround, but it's not that good:

DllChaOwn:dword[6]:=[&DllChaV[0],&DllChaV[4]+4,&DllChaV[8]+8,&DllChaV[12]+12,&DllChaV[16]+16,&DllChaV[20]+20];

A real solution would be better.

jj2007

I don't know HLA, so it's difficult to judge what's going on under the hood. In Masm this would look like this:

include \masm32\include\masm32rt.inc

.code
DllChaOwn dd DllChaV[0], DllChaV[4], DllChaV[8], DllChaV[12], DllChaV[16], DllChaV[20]
DllChaV dd 49990, 80h, 80h, 80h, 80h, 80h

start: xor ebx, ebx
.Repeat
print str$(ebx), 9
print str$(DllChaOwn[4*ebx]), 9
mov eax, DllChaOwn[4*ebx]
mov eax, [eax] ; dereferenced
print str$(eax), 13, 10
inc ebx
.Until ebx>5
inkey "OK"
exit
end start


Output are the pointers to the second array, plus its values:

0       4198424 49990
1       4198428 128
2       4198432 128
3       4198436 128
4       4198440 128
5       4198444 128

Sorry if I can't be of more help...

Dav92

Thanks anyway for your help, so for now I have to use my workaround.

Sevag.K

looks like a bug with hla, i'll notify Randall.

hla is ignoring the address reference for every item after the first ( see the hlaba source ).

for the workaround, you can leave out the [] referencing.

program tt;
#include("stdlib.hhf")

static

DllChaOwn:dword[6]:= [ &DllChaV, &DllChaV+4, &DllChaV+8, &DllChaV+12, &DllChaV+16, &DllChaV+20 ];
DllChaV:dword[6]:=[49990,$80,$80,$80,$80,$80];

begin tt;

for( mov( 0, ecx ); ecx < @elements( DllChaOwn ); inc( ecx ) ) do

mov( DllChaOwn[ecx*4], ebx );
mov( [ebx], eax );
stdout.put( ">", ebx, "  >", eax, nl );

endfor;


end tt;



Dav92

Ok, thx, then I'll use that meanwhile.