flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > array of struc with defined data |
Author |
|
vid 24 Jun 2004, 20:10
yours way won't be possible, "." and "[","]" have sbosolutely different meaning in FASM. You can make it by defining both struct RECT and macro RECT:
Code: macro RECT a1,a2,a3,a4 { dd a1,a2,a3,a4 } and then you can do Code: cliplist RECT 0,0,100,100 RECT 100,100,200,200 there are some macros, which define both macro and struc for you, you can find them somewhere in board (but don't know where, sorry) btw, yours way to do it is okay. |
|||
24 Jun 2004, 20:10 |
|
madmatt 25 Jun 2004, 00:51
Hello vid,
vid wrote: yours way won't be possible, "." and "[","]" have sbosolutely different meaning in FASM. You can make it by defining both struct RECT and macro RECT: 1. I know it wouldn't be possible with FASM now. The way I suggested would mean that FASM would have to be modified to handle the data of structs and the accessing method. 2. Accessing individual components your way would be unclear when coding it into assembly. vid wrote: there are some macros, which define both macro and struc for you, you can find them somewhere in board (but don't know where, sorry) I might have those macros somewhere, but this should be a hardcoded feature in fasm for some future time. This would help in making more complex windows/directx/direct3d programming easier and more intuitive. Madmatt |
|||
25 Jun 2004, 00:51 |
|
vid 25 Jun 2004, 06:53
don't believe it, to using your method would require to CHANGE (break backward compatiblity) FASM's logic in many things, where it isn't nescessary.
|
|||
25 Jun 2004, 06:53 |
|
Tommy 25 Jun 2004, 07:41
I agree with you, vid.
|
|||
25 Jun 2004, 07:41 |
|
madmatt 25 Jun 2004, 08:12
My way above was a suggested way, NOT the only way. There is NO reason why FASM can't have this feature in some future version. Not EVERYTHING can be done in macros. Of course, privalov has the final say on this matter, I simply don't have the time to go through the code and try and figure out where to make the changes, test and debug the thing. It might be a somewhat complex to implement, but I don't think it is impossible. This would make fasm much more powerful for large projects in windows, or smaller projects for that matter.
MadMatt |
|||
25 Jun 2004, 08:12 |
|
vid 25 Jun 2004, 20:35
It will also make it much less comrehensible ("." behavior will become funny), you will have to change local labels system totally, it would require many changes to preprocessor, "[]" would be used for both array-addressing and memory-addressing etc. etc. thus becoming unclear.
In my opinion you are too used to high level languages, using asm too short, and you still didn't get the "assembly" way of thinking when writing code. |
|||
25 Jun 2004, 20:35 |
|
madmatt 26 Jun 2004, 04:03
Defining data the way I stated:
Code: myrect RECT = [ [0,0,100,100],[200,200,300,300],[400,100,500,200],[500,400,550,450] ] shouldn't be much of a problem, and shouldn't require major changes to the way fasm does things. Just check for '=' sign after fasm is certain it is a valid 'RECT' struc , and then process and error check the data following it. Same thing with accessing the data: Code: mov eax,myrect[3].top ;4th RECT array, variable .top just check if there was a leading '[' if not, then if fasm finds one right next to a variable then must be array of something, so check if valid struc define and process other parts of the struct. Quote: In my opinion you are too used to high level languages, using asm too short, and you still didn't get the "assembly" way of thinking when writing code. I've been writing in assembly more than any other language combined. If the 'assembly way' of doing things means doing every other thing the 'hard confusing way', then you can have it. my code above looks clearer than 'mov eax,[myrect.top+ecx]'. Having 'some' High level features in fasm is a plus, especially when writing windows and mmx/sse/sse2 assembly code, which is the whole reason I'm asking for this. MadMatt |
|||
26 Jun 2004, 04:03 |
|
Tommy 26 Jun 2004, 07:00
Why not:
Code: macro _RECT name, x1,y1,x2,y2 { name#.left dd x1 name#.top dd y1 name#.right dd x2 name#.bottom dd y2 } struc RECT [name,x] { common virtual at $ .left dd ? .top dd ? .right dd ? .bottom dd ? end virtual .count = 0 forward _RECT .#name,x .count = .count + 1 } f RECT item1,<0,0,100,100>, item2,<25,25,50,50>, item3,<100,100,200,200> Code: f.item1.left f.item1.top ... f.item3.right f.item3.bottom f.count |
|||
26 Jun 2004, 07:00 |
|
vid 26 Jun 2004, 07:18
the way tommy proposed will work, of course, but your's wouldnt.
Quote:
Don't forget struc is just another type of macro, so after checking it is valid RECT structure, it must expand RECT "macro" (or structure - almost same thing). Really, try to mess with FASM somewhat longer and you will realize why it isn't possible (at least not the way you suggested) |
|||
26 Jun 2004, 07:18 |
|
madmatt 26 Jun 2004, 12:49
Tommys suggestion is fine, but what about all the other hundreds, (if not thousands) of windows structures, do you want me to redefine each and every one of them too?
using: Code: mov eax,myrect[4].top Why would this cause fasm trouble? This is good, the compiler does all the calculating, and this code looks more readable than something like: Code: mov eax,[myrect.top+ecx] Code: myrect RECT = [ [0,0,100,100],[200,200,300,300],[400,100,500,200],[500,400,550,450] ] Is a reasonable request, and doable, and would be useful for setting up (array of) structures quickly with predefined values. |
|||
26 Jun 2004, 12:49 |
|
vid 26 Jun 2004, 14:51
not with "[]" characters, maybe "<". Using "[" it will be hard to pass argument containing "[" to structure. Also, it will be problem to create names like "myrect[3].a" now
|
|||
26 Jun 2004, 14:51 |
|
madmatt 26 Jun 2004, 21:23
That sounds good also, whatever makes it the easiest to implement. Actually, the data defining is what I'm really looking for. I thought I would throw in the array access method just for completness. I think I remember some macros that were made a few months ago in the 'macro instructions' forum that does at least some of what I'm looking for. However, It would be better to have these hardcoded into the fasm compiler.
|
|||
26 Jun 2004, 21:23 |
|
vid 27 Jun 2004, 10:00
i don't think so. And be sure that if it can be acheived by macros, then Privalov won't hardcode it into FASM.
|
|||
27 Jun 2004, 10:00 |
|
S.T.A.S. 27 Jun 2004, 15:22
madmatt wrote:
BTW, how will compiler figure out the use of ECX in the first case? |
|||
27 Jun 2004, 15:22 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.