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 > Linux > Implementing C structures in x86 assembly

Author
Thread Post new topic Reply to topic
alkap



Joined: 18 Feb 2015
Posts: 39
Location: Dnipro, Ukraine
Implementing C structures in x86 assembly
Is this how C structures are implemented in x86 Linux assembly?
I believe the Windows fasm distribution defines a 'struc' macros, while the Linux one does not. Correct me if I am wrong. Thanks.


Code:

; fasm struct_test.fasm struct_test

format ELF executable 3
entry start

segment readable executable

start:

        mov     eax4
        mov     ebx1
        mov     ecxmsg.str
        mov     edxmsg.len
        int     80h

        mov     eax,1
        xor     ebx,ebx
        int     80h

segment readable writeable

msg:                                                    ; struct msg?
        .str    db 'Hello world!',0xA
        .len = $-.str


Post 17 May 2015, 06:26
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14928
Location: 6EQUJ5
You can also use the struct macros for linux code if you wish to. They are quite a nice convenience. On the other hand you could manually construct them using the struc macro. Or on the third hand you can do what you did above and have no structure at all but instead do all the computations independently.
Post 17 May 2015, 07:25
View user's profile Send private message Visit poster's website Reply with quote
alkap



Joined: 18 Feb 2015
Posts: 39
Location: Dnipro, Ukraine
Understood. Thanks.
I did look through the include files that come with the Linux distribution of fasm, but failed to find where the 'struct' macro is defined.
Do I have to include the Windows STRUCT.INC in my Linux source files to make use of the 'struct' macro?
Thanks.
Post 17 May 2015, 07:54
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14928
Location: 6EQUJ5

alkap wrote:
I did look through the include files that come with the Linux distribution of fasm, but failed to find where the 'struct' macro is defined.
Do I have to include the Windows STRUCT.INC in my Linux source files to make use of the 'struct' macro?

Yes, you will need to include it in some way to make use of it. You could also copy the text and paste it into your main source if that makes more sense to you to avoid having includes.
Post 17 May 2015, 09:58
View user's profile Send private message Visit poster's website Reply with quote
alkap



Joined: 18 Feb 2015
Posts: 39
Location: Dnipro, Ukraine
Understood. I'll give that a try. Thanks.
Post 17 May 2015, 14:04
View user's profile Send private message Send e-mail 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.