flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > misunderstood with stuct

Author
Thread Post new topic Reply to topic
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 08 Nov 2005, 20:39
maybe i missed something, but can't get to work the 'struct', what i am doing wrong?

the code:
Code:
push [edi+IMAGE_SECTION_HEADER.VirtualSize]
pop  [edi+IMAGE_SECTION_HEADER.SizeOfRawData]
    


assembled to:
Code:
  push    dword ptr ds:[edi]
  pop     dword ptr ds:[edi+10]
    


but should assembled to:
Code:
  push    dword ptr ds:[edi+8]
  pop     dword ptr ds:[edi+10]
    


my struct:

Code:
struct IMAGE_SECTION_HEADER
  Name                  rb IMAGE_SIZEOF_SHORT_NAME
  union
  PhysicalAddress       dd ?
  VirtualSize           dd ?
  ends
  VirtualAddress        dd ?
  SizeOfRawData         dd ?
  PointerToRawData      dd ?
  PointerToRelocations  dd ?
  PointerToLinenumbers  dd ?
  NumberOfRelocations   dw ?
  NumberOfLinenumbers   dw ?
  Characteristics       dd ?
ends
    


original structure from masm:
Code:
IMAGE_SECTION_HEADER STRUCT
    Name1 db 8 dup(?)
    union Misc
        PhysicalAddress dd  ?
        VirtualSize dd      ?
    ends
    VirtualAddress dd       ?
    SizeOfRawData dd        ?
    PointerToRawData dd     ?
    PointerToRelocations dd ?
    PointerToLinenumbers dd ?
    NumberOfRelocations dw  ?
    NumberOfLinenumbers dw  ?
    Characteristics dd      ?
IMAGE_SECTION_HEADER ENDS
    

_________________
[not enough memory]
Post 08 Nov 2005, 20:39
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2 08 Nov 2005, 21:32
Try getting rid of the union and see if that works
Post 08 Nov 2005, 21:32
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 08 Nov 2005, 22:20
That was bug in "struct" macro that went unnoticed - thanks for finding it out. Updated the fasmw package with the fixed version.
Post 08 Nov 2005, 22:20
View user's profile Send private message Visit poster's website Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier 09 Nov 2005, 07:13
This structure is used to Print an RTF document directly to printer. Using the latest 08 November FASM, the following struct does not pass assembly. Yesterday, it did:

Code:
CCHDEVICENAME           equ 32
CCHFORMNAME                     equ 32

DEVMODE struct
  dmDeviceName      db   CCHDEVICENAME dup (?)          ;0
  dmSpecVersion     dw      ?                                           ;32
  dmDriverVersion   dw      ?                                           ;34
  dmSize            dw      ?                                           ;36
  dmDriverExtra     dw      ?                                           ;38
  dmFields          dd      ?                                           ;+40
  union                                                                                         ;+44
     struct
        dmOrientation dw ?
        dmPaperSize dw ?
        dmPaperLength dw ?
        dmPaperWidth dw ?
     ends
      dmPosition POINT
  ends
  dmScale           dw      ?                                           ;52
  dmCopies          dw      ?                                           ;+54
  dmDefaultSource   dw      ?                                           ;56
  dmPrintQuality    dw      ?                                           ;58
  dmColor           dw      ?                                           ;60
  dmDuplex          dw      ?                                           ;62
  dmYResolution     dw      ?                                           ;64
  dmTTOption        dw      ?                                           ;66
  dmCollate         dw      ?                                           ;+68
  dmFormName        db CCHFORMNAME dup (?)
  dmLogPixels       dw      ?
  dmBitsPerPel      dd      ?
  dmPelsWidth       dd      ?
  dmPelsHeight      dd      ?
  dmDisplayFlags    dd      ?
  dmDisplayFrequency  dd      ?
  dmICMMethod       dd ?
  dmICMIntent       dd ?
  dmMediaType       dd ?
  dmDitherType      dd ?
  dmReserved1       dd ?
  dmReserved2       dd ?
DEVMODE ends
    


Error report:
DEVMODE ends
\Program Files\fasm\include\macro\masm.inc [9] ends [0]:
{ match =.,name@struct \{ ends \} }
\Program Files\fasm\include\macro/struct.inc [60] ends [6]:
make@struct name,fields
\Program Files\fasm\include\macro/struct.inc [76] make@struct [9]:
match , field \{ make@substruct type,name,sub def
\Program Files\fasm\include\macro/struct.inc [120] make@substruct [6]:
make@substruct type,name,sub def
\Program Files\fasm\include\macro/struct.inc [125] make@substruct [11]:
match fields, define \\{ define@\#substruct fields \\} \} }
\Program Files\fasm\include\macro/struct.inc [161] define@substruct [1]:
virtual at parent#.#name
error: undefined symbol.

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 09 Nov 2005, 07:13
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 09 Nov 2005, 09:51
Please check it now.
Post 09 Nov 2005, 09:51
View user's profile Send private message Visit poster's website Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 09 Nov 2005, 14:12
thanks for fast fixes, Tomasz, i think it was critical error

this struct also isn't working, it's normal? i mean virtual at structure member

Code:
struct IMAGE_SECTION_HEADER
  Name                  rb IMAGE_SIZEOF_SHORT_NAME
  misc                  rb 8
  virtual at misc
  PhysicalAddress       dd ?
  VirtualSize           dd ?
  end virtual
  VirtualAddress        dd ?
  SizeOfRawData         dd ?
  PointerToRawData      dd ?
  PointerToRelocations  dd ?
  PointerToLinenumbers  dd ?
  NumberOfRelocations   dw ?
  NumberOfLinenumbers   dw ?
  Characteristics       dd ?
ends
    
Post 09 Nov 2005, 14:12
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier 09 Nov 2005, 14:37
Looks great!

Not only does it assemble without error, it runs exactly the way it should.

Thanks for your excellent product!!!

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 09 Nov 2005, 14:37
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 09 Nov 2005, 15:11
No, you should not use "virtual" inside "struct", only the data definitions, and no other directives etc.
Post 09 Nov 2005, 15:11
View user's profile Send private message Visit poster's website Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 09 Nov 2005, 16:54
ok, thanks
Post 09 Nov 2005, 16:54
View user's profile Send private message 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.