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 > Question about includes and libraries

Author
Thread Post new topic Reply to topic
eightlimbed



Joined: 22 Nov 2017
Posts: 3
Question about includes and libraries
Hi,

I'm interested in learning assembly and I signed up for a course on udemy called Assembly Language Adventures by xorpd. He recommended this forum as a good place to ask questions.

His whole course is based on working in a Windows environment, but I prefer Linux. I'm using Ubuntu 16.04.1.

In this course I'm at the stage where I'm actually starting to read and write programs. Here is the first one:


Code:

; example for a very basic fasm program. (console based).

format PE console
entry start

include 'win32a.inc'

; =======================================
section '.text' code readable executable

start:
        ; program begins
        inc             eax
        inc             eax
        dec             eax
        inc             eax

        ; exit the process
        push    0
        call            [ExitProcess]

; =======================================
; Imports Section

section '.idata' import data readable

library kernel,'kernel32.dll'

import kernel,\
           ExitProcess,'ExitProcess'




I believe the program is including some library file that contains the 'ExitProcess'.

As a linux user, is there a similar library that I can include instead?

I assume there will be more library includes coming up in the course and I'm wondering how I should go about following along. I don't want to abandon the course because I think the instructor and the content is great. I've already learned a lot, but I want to write some programs now! Smile

Thanks for reading.
Post 22 Nov 2017, 03:16
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15242
Location: 1I/╩╗Oumuamua
Linux is very different from Windows. I guess you already knew that. If all you need are simple OS services like opening a file or writing to the console then you don't need to load any libraries. It is all done with system calls or software interrupts.

There are examples programs in the linux version of the fasm download:

Code:

; fasm demonstration of writing simple ELF executable

format ELF executable 3
entry start

segment readable executable

start:

        mov     eax,4
        mov     ebx,1
        mov     ecx,msg
        mov     edx,msg_size
        int     0x80

        mov     eax,1
        xor     ebx,ebx
        int     0x80

segment readable writeable

msg db 'Hello world!',0xA
msg_size = $-msg

Post 22 Nov 2017, 03:24
View user's profile Send private message Visit poster's website Reply with quote
eightlimbed



Joined: 22 Nov 2017
Posts: 3
Thanks, Revolution, the examples are helpful.
Post 22 Nov 2017, 18:13
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


Powered by phpBB © 2001-2005 phpBB Group.

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