flat assembler
Message board for the users of flat assembler.

Index > Linux > Implementing C structures in x86 assembly

Author
Thread Post new topic Reply to topic
alkap



Joined: 18 Feb 2015
Posts: 44
Location: Dnipro, Ukraine
alkap 17 May 2015, 06:26
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     eax, 4
        mov     ebx, 1
        mov     ecx, msg.str
        mov     edx, msg.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: 20454
Location: In your JS exploiting you and your system
revolution 17 May 2015, 07:25
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: 44
Location: Dnipro, Ukraine
alkap 17 May 2015, 07:54
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: 20454
Location: In your JS exploiting you and your system
revolution 17 May 2015, 09:58
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: 44
Location: Dnipro, Ukraine
alkap 17 May 2015, 14:04
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


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.