flat assembler
Message board for the users of flat assembler.
  
|  Index
      > Main > struct question | 
| Author | 
 | 
| revolution 04 Jan 2024, 14:54 To supply multiple items to a single member use angle brackets.     Code: tp TRIS <1,2> | |||
|  04 Jan 2024, 14:54 | 
 | 
| DenimJeans 04 Jan 2024, 15:07 thanks revolution, indeed I tried all combinations of {[(, but not the angle brackets .. haha
 perfect thanks! and creating an array of the struct via macro to access them later via named label also possible? so I access them later via tp1 .. tp100 ..... Code: mov eax,[tp1+TRIS.pt1.x] | |||
|  04 Jan 2024, 15:07 | 
 | 
| revolution 04 Jan 2024, 15:25 Code: tp1: rb sizeof.TRIS * 100 | |||
|  04 Jan 2024, 15:25 | 
 | 
| DenimJeans 04 Jan 2024, 15:45 ok, nice, thanks again. 
 just for completeness: Code: struct TRIS pt1 POINT 8,9 ends t1: rept 100 { local pt pt TRIS } would also copy the initialized values (8,9) to the copies and your suggestion initialize with unknown (0) values. Have a great day, thanks DJ | |||
|  04 Jan 2024, 15:45 | 
 | 
| AsmGuru62 04 Jan 2024, 19:10 Also, to use structures inside procedures as local variables:
 Code: proc foo uses ebx esi edi, param1:DWORD, param2:DWORD local var1:TRIS local arrayOfThose[16]:TRIS ; ; load a pointer to a single structure variable into EAX ; lea eax, [var1] ; ; load a structure member of 'var1' into ECX ; mov ecx, [eax + TRIS.xxxxxx] ; ; load pointer to array into ESI ; lea esi, [arrayOfThose] add esi, sizeof.TRIS ; ESI --> next array element add esi, sizeof.TRIS ; ESI --> next array element add esi, sizeof.TRIS ; ESI --> next array element add esi, sizeof.TRIS ; ESI --> next array element ; ... you get it?.. ret endp | |||
|  04 Jan 2024, 19:10 | 
 | 
| DenimJeans 05 Jan 2024, 07:28 that also nice, thanks AsmGuru62
 how can I access for example the 10th element then? like so or is there a simpler way: Code: local arrayOfThose[16]:TRIS lea esi,[arrayOfThose] mov eax,10 mov ecx,sizeof.TRIS mul ecx add esi ,eax mov [esi+TRIS.pt.x],0x11111111 mov [esi+TRIS.pt.y],0x22222222 and 2nd question: assigning values to the 10th item would not be possible, right? I need to access them each single by using their members?: Code: arrayOfThose[10] <0x111111,0x222222>,0x555555,0x666666 ;wrong? mov [esi+TRIS.pt.x],0x11111111 ;correct? | |||
|  05 Jan 2024, 07:28 | 
 | 
| revolution 05 Jan 2024, 08:08 To access the 10th element.     Code: mov [arrayOfThose + 9 * sizeof.TRIS + TRIS.pt.x],0x11111111 ; first element is index 0, second is 1, etc. | |||
|  05 Jan 2024, 08:08 | 
 | 
| DenimJeans 05 Jan 2024, 09:06 thanks revolution. works now as expected. 
 and the ".data" section requires to be at the beginning and not end of the assembly, right? Otherwise it does not work for me. | |||
|  05 Jan 2024, 09:06 | 
 | 
| revolution 05 Jan 2024, 09:27 There are no location requirements for any sections. Put them anywhere. | |||
|  05 Jan 2024, 09:27 | 
 | 
| < Last Thread | Next Thread > | 
| Forum Rules: 
 | 
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.