flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Request/suggestion for zero length structure fields

Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20337
Location: In your JS exploiting you and your system
revolution 12 Feb 2008, 16:28
When using the fasm package STRUCT.INC, I tried to do this:
Code:
struct foo_header
       field1 rd 1
 field2 dd ?
...
  var_data rb 0  ;a field indicating where data starts
ends    


It errors due to the last field generating the line "foo_header.var_data db 0 dup (?)".

With the standard assembler (not macro) struc we can do this easily:
Code:
struc foo_header {
     .field1 rd 1
        .field2 dd ?
...
 .var_data rb 0  ;a field indicating where data starts
}    


But the is no equivalent way to do this using the macro version.

There are two ways to solve this.
1) Modify the macros in STRUCT.INC like this:
Code:
macro struct name
...
   struc rb count \{ define field@struct .,rb,count   ;modified here
                   fields@struct equ fields@struct,field@struct \}
   struc rw count \{ define field@struct .,rw,count ;modified here
                   fields@struct equ fields@struct,field@struct \}
   struc rd count \{ define field@struct .,rd,count ;modified here
                   fields@struct equ fields@struct,field@struct \}
   struc rp count \{ define field@struct .,rp,count ;modified here
                   fields@struct equ fields@struct,field@struct \}
   struc rq count \{ define field@struct .,rq,count ;modified here
                   fields@struct equ fields@struct,field@struct \}
   struc rt count \{ define field@struct .,rt,count ;modified here
...    
or, 2) Modify the assembler to allow zero duplications like "db 0 dup (?)".

So ... my request/suggestion is to change the setup in the next version using either of these two solutions. I think the preferred option is the first where STRUCT.INC is changed.
Post 12 Feb 2008, 16:28
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 12 Feb 2008, 16:37
in standard struc, just use label, no? not sure about STRUCT, never used it Smile
Post 12 Feb 2008, 16:37
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20337
Location: In your JS exploiting you and your system
revolution 12 Feb 2008, 16:47
vid wrote:
in standard struc, just use label, no? not sure about STRUCT, never used it Smile
Can't use label because it is not correctly initialised, it would always be zero. The struct macro is generated inside a virtual block and only initialised after the ends, that is also why you can't put code inside the struct whereas for struc you can put code.
Post 12 Feb 2008, 16:47
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20337
Location: In your JS exploiting you and your system
revolution 20 Dec 2008, 12:37
*BUMP*

I think my suggestion above has been forgotten about Sad
Post 20 Dec 2008, 12:37
View user's profile Send private message Visit poster's website Reply with quote
kempis



Joined: 12 Jun 2008
Posts: 49
kempis 20 Dec 2008, 13:53
What about

Code:
macro struct name
...
   macro label ...
...    
Post 20 Dec 2008, 13:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20337
Location: In your JS exploiting you and your system
revolution 20 Dec 2008, 13:58
What about it?
Post 20 Dec 2008, 13:58
View user's profile Send private message Visit poster's website Reply with quote
kempis



Joined: 12 Jun 2008
Posts: 49
kempis 21 Dec 2008, 07:32
Code:
...
macro label var\{ define field@struct var,:,
                  fields@struct equ fields@struct,field@struct
...     
Post 21 Dec 2008, 07:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20337
Location: In your JS exploiting you and your system
revolution 21 Dec 2008, 08:39
Okay, sure, that can be added also for unsized labels. We also need to add "purge label".
Post 21 Dec 2008, 08:39
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.