flat assembler
Message board for the users of flat assembler.

Index > Main > 'Struct' definition.

Author
Thread Post new topic Reply to topic
khanh



Joined: 25 Jul 2003
Posts: 27
khanh 03 Jun 2004, 14:31
I've seen this in the Fasm package:

Code:
macro struct name
 { virtual at 0
   name name
   sizeof.#name = $ - name
   name equ sizeof.#name
   end virtual }
    


If I understand correctly, after this 'name' is equal to sizeof structure?Why?
For example if this structure is decleared:

Code:
struc SYSTEMINFO
 {
   .wProcessorArchitecture      dw ?
   .wReserved                   dw ?
   .dwPageSize                  dd ?
   .lpMinimumApplicationAddress dd ?
   .lpMaximumApplicationAddress dd ?
   .dwActiveProcessorMask       dd ?
   .dwNumberOfProcessors        dd ?
   .dwProcessorType             dd ?
   .dwAllocationGranularity     dd ?
   .wProcessorLevel             dw ?
   .wProcessorRevision          dw ?
 }
struct SYSTEMINFO
    

so Systeminfo = sizeof Systeminfo ?

I'm newbie!
Post 03 Jun 2004, 14:31
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 03 Jun 2004, 19:19
Yes, this is the intention.

However, it is better to always use sizeof.NAME form. It is safer because in some situations you cannot use only the name.
And because source is more readable.

BTW, I prefer to use NAME.size because is nicer and I find it more homogeneous nomenclature.
Post 03 Jun 2004, 19:19
View user's profile Send private message Yahoo Messenger Reply with quote
khanh



Joined: 25 Jul 2003
Posts: 27
khanh 03 Jun 2004, 20:26
Thank for your quicl reply Wink
Post 03 Jun 2004, 20:26
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.