flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Main > Defining a structure

Author
Thread Post new topic Reply to topic
jorido



Joined: 23 Jan 2017
Posts: 53
Defining a structure
How to define a simple structure? I've seen this:


1)


Code:


struc point xyz
{
    .x db x,
    .y db y,
    .z db z
}






2)

Code:

  struct POINT
    x db ?
    y db ?
    z db ?
  ends




Questions:
a) is it struc or struct?
b) why { ... } in #1?
c) why arguments in #1?
d) or are these just 2 different ways to do basically the same thing?

And:

e) What's the most common convention for naming a structure: MY_STRUCT? Or MyStruct? Or my_struct? Or anything else?
Post 24 Jan 2017, 18:14
View user's profile Send private message Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
They're different things.

The first one, struc, is a directive that is provided by FASM. http://flatassembler.net/docs.php?article=manual#2.3.4

The second, struct, is a macro that is defined in win32a.inc. http://flatassembler.net/docs.php?article=win32#1.1
Post 24 Jan 2017, 18:42
View user's profile Send private message Reply with quote
jorido



Joined: 23 Jan 2017
Posts: 53
Which one and when is used?
Post 24 Jan 2017, 19:29
View user's profile Send private message Reply with quote
jorido



Joined: 23 Jan 2017
Posts: 53
What if I had a structre with 10 fields, would I have to list all of them as arguments?


Code:

struc point a1a2a3a4a5a6a7a8a9a10
{
  .........



Post 25 Jan 2017, 07:38
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15237
Location: 1I/╩╗Oumuamua
If you have a fixed number of arguments then, yes, you have to list them all if you need to initialise the values at the time of definition. If you have a variable number of arguments then you can use square brackets [args] to define the name and loop through the values with forward and reverse.
Post 25 Jan 2017, 08:00
View user's profile Send private message Visit poster's website Reply with quote
jorido



Joined: 23 Jan 2017
Posts: 53
>If you have a fixed number of arguments then, yes, you have to list them all if you need to initialise the values at the time of definition.

If I have a fixed number of them but don't want to initialise the values?



Alright, and how about:

e) What's the most common convention for naming a structure: MY_STRUCT? Or MyStruct? Or my_struct? Or anything else?
Post 25 Jan 2017, 09:11
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15237
Location: 1I/╩╗Oumuamua

jorido wrote:
If I have a fixed number of them but don't want to initialise the values?

Then just use a bare stuc with no defined parameters

jorido wrote:
e) What's the most common convention for naming a structure: MY_STRUCT? Or MyStruct? Or my_struct? Or anything else?

There is not really a common convention. Basically do whatever makes sense to you in your project. Your boss (if you have one) may dictate to you what naming conventions to use. They are arbitrary, but important.
Post 25 Jan 2017, 10:19
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.