flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Bug in struct macro

Author
Thread Post new topic Reply to topic
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 28 Dec 2007, 02:49
(Not really related to fasm internals)

There is a bug in struct macro of win32 package.

Code:
  struct WBB
    word dw ?
      struct
        byte1 db ?
        byte2 db ?
      ends
  ends

alpha WBB

mov dl, [alpha.byte2] ; Works
mov al, [ebx+WBB.byte1] ; Works    


However:
Code:
 struct WBB
   union
     word dw ?
       struct
         byte1 db ?
         byte2 db ?
       ends
   ends
 ends

alpha WBB

mov dl, [alpha.byte2] ; Works
mov al, [ebx+WBB.byte1] ; Error: undefined symbol 'WBB.byte1'
    
Post 28 Dec 2007, 02:49
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 28 Dec 2007, 05:20
It is documented, you cannot have structs in anonymous unions.
Post 28 Dec 2007, 05:20
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 28 Dec 2007, 05:29
http://flatassembler.net/docs.php?article=win32 <- Where it says that?

Also note that the documentation has a more complex example:
Code:
  struct LINE
    union
      start POINT
      struct
        x1  dd ?
        y1  dd ?
      ends
    ends
    union
      end   POINT
      struct
        x2  dd ?
        y2  dd ?
      ends
    ends
  ends
    
Post 28 Dec 2007, 05:29
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 28 Dec 2007, 05:45
replace union with struct and the same error results.
Post 28 Dec 2007, 05:45
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 28 Dec 2007, 05:50
Seems that nesting is not properly supported for offsets constants (struct_name.field), however works correctly when you define a variable and access the fields throught variable name (var_name.field).
Post 28 Dec 2007, 05:50
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8358
Location: Kraków, Poland
Tomasz Grysztar 01 Mar 2009, 18:06
I've got it fixed (hopefully) with today's update.
Post 01 Mar 2009, 18:06
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.