flat assembler
Message board for the users of flat assembler.
Index
> Windows > How to define a local structure more than one time? |
Author |
|
revolution 31 May 2020, 07:36
It depends upon how you define your Point structure.
You could do it like this: Code: struc Point replications { dd replications dup (?,?) } |
|||
31 May 2020, 07:36 |
|
extra_12345 31 May 2020, 07:54
revolution wrote: It depends upon how you define your Point structure. For example point contains x and y arguments,so I've define my structure like this: struc Point replications { dd replications dup (?,?) x dd ? y dd ? } Then in my procedure: Local replications 25 Right? Can you please be a little bit more specific?thank you |
|||
31 May 2020, 07:54 |
|
revolution 31 May 2020, 08:07
To define labels within that you might want to do this:
Code: struc Point replications { x dd ? y dd ? dd replications-1 dup (?,?) } Code: Local my_points Point 25 |
|||
31 May 2020, 08:07 |
|
extra_12345 31 May 2020, 08:45
so let me get this straight,i have this structure:
Code: struct EnochFA alpha dd ? x dd ? y dd ? bright dd ? lpstr dd ? timer dd ? dum1 dd ? dum2 dd ? ends to be able to define it more than once i have to modify it such as: Code: struct EnochFA alpha dd ? x dd ? y dd ? bright dd ? lpstr dd ? timer dd ? dum1 dd ? dum2 dd ? dd EnochFA dup (?,?) ends and in my procedure: Code: local enochl EnochFA 25 but at runtime " invalid argument" pops up right on the above local definition,i think i did something wrong?! |
|||
31 May 2020, 08:45 |
|
revolution 31 May 2020, 09:33
When you use struct that is a macro, not the fasm native struc.
If you are using the normal fasm package struct then it doesn't support repetitions like that. |
|||
31 May 2020, 09:33 |
|
Tomasz Grysztar 31 May 2020, 09:46
It is one of the questions that had been answered in the old FAQ:
Quote: How to define an array of structures? I considered this FAQ deprecated, in favor of more recently updated FAQs on this board, but if such questions keep showing up perhaps we should copy these old answers to the forum-hosted FAQs somewhere. |
|||
31 May 2020, 09:46 |
|
extra_12345 31 May 2020, 10:22
Tomasz Grysztar wrote: It is one of the questions that had been answered in the old FAQ: That worked flawlessly,thank you Tomasz. |
|||
31 May 2020, 10:22 |
|
revolution 31 May 2020, 10:24
Tomasz Grysztar wrote: It is one of the questions that had been answered in the old FAQ: But like this we can make the label StrucArray more useful. Code: StrucArray MYSTRUC rept 100-1 { local ..s ..s MYSTRUC } Code: mov eax,[StrucArray.x] ; access the x value within MYSTRUC |
|||
31 May 2020, 10:24 |
|
Tomasz Grysztar 31 May 2020, 10:36
revolution wrote: Neither of those gives access to the structure labels. Code: mov eax,[ebx+MYSTRUC.x] |
|||
31 May 2020, 10:36 |
|
revolution 31 May 2020, 11:05
Tomasz Grysztar wrote:
|
|||
31 May 2020, 11:05 |
|
Roman 31 May 2020, 11:07
Quote: StrucArray MYSTRUC How get from 10 StrucArray mov eax,[StrucArray.x+sizeof.MYSTRUC*10] ? Or exist another way ? mov eax,[StrucArray.x] get first from StrucArray |
|||
31 May 2020, 11:07 |
|
revolution 31 May 2020, 11:40
It would be best if we can pick up the size from the defined label, not the structure itself.
Code: mov eax,[StrucArray.x + sizeof.StrucArray * 10] Code: StrucArray MYSTRUC2 ; new name rept 100-1 { local ..s ..s MYSTRUC2 ; new name } ;... mov eax,[StrucArray.x + sizeof.StrucArray * 10] ; no change |
|||
31 May 2020, 11:40 |
|
Tomasz Grysztar 31 May 2020, 12:01
revolution wrote: It would be best if we can pick up the size from the defined label, not the structure itself. Code: include 'macro/struct.inc' include 'cpu/p6.inc' struct MYSTRUC2 x dd ? ends StrucArray MYSTRUC2 rept 100-1 MYSTRUC2 end rept mov eax,[StrucArray.x + sizeof StrucArray * 10] Code: struc starr? name*, count:1 label . : sizeof name * count .item name rept count-1 name end rept end struc StrucArray starr MYSTRUC2,100 mov ecx,sizeof StrucArray mov eax,[StrucArray.item.x + sizeof StrucArray.item * 10] I would say that seeing all the differing preferences for code/syntax patterns (discussed on the forums from the beginning of their history) was probably one of the main motivators for me to design fasmg with its frenzied levels of customizability. |
|||
31 May 2020, 12:01 |
|
bitRAKE 31 May 2020, 18:53
Reading through your latest struct implementation, I couldn't think of a situation where it didn't work. Just amazing, and a great "go-to" for what is possible.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
31 May 2020, 18:53 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.