flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > mixing c with fasm

Author
Thread Post new topic Reply to topic
cthug



Joined: 03 Apr 2009
Posts: 36
Location: /home/Australia
cthug 03 Apr 2009, 23:18
OK say I have 2 object (ELF object, unix/linux), the first is written in c, second in fasm, now i want to encorporate fasm's "file" directive into my c program, so my question is, how can i make a variable in fasm that i can use in my c application. btw I am using gcc on linux ubuntu, but I will be porting using mingw, on windows.

_________________
"There are only two industries that refer to their customers as 'users'." Edward Tufte
Post 03 Apr 2009, 23:18
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20339
Location: In your JS exploiting you and your system
revolution 03 Apr 2009, 23:28
The way to achieve that is with the use of extrn/public and use a linker.
Post 03 Apr 2009, 23:28
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Apr 2009, 23:28
Do you want to extract "file" functionality from fasm or getting the file contents from an assembly source which contains a "file" directive invocation somewhere?
Post 03 Apr 2009, 23:28
View user's profile Send private message Reply with quote
cthug



Joined: 03 Apr 2009
Posts: 36
Location: /home/Australia
cthug 03 Apr 2009, 23:37
I want to have an asm file like:

format ELF

file variable, "SOMEFILE"

C File:

int main() {
printf("Variable: %s", variable);
}

compile with like:

fasm test.asm test.o
gcc main.c -c -o main.o
gcc main.o test.o -o test

NOTE: I wrote this quickly so it may not be correct
Post 03 Apr 2009, 23:37
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20339
Location: In your JS exploiting you and your system
revolution 03 Apr 2009, 23:42
Put 'variable' as public in the fasm file and as extrn in the C file and rewrite the line as "variable: file 'SOMEFILE'".
Post 03 Apr 2009, 23:42
View user's profile Send private message Visit poster's website Reply with quote
cthug



Joined: 03 Apr 2009
Posts: 36
Location: /home/Australia
cthug 03 Apr 2009, 23:56
ty I shall test Wink
Post 03 Apr 2009, 23:56
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1902
DOS386 05 Apr 2009, 03:23
Move to Linux or High Level Languages ?
Post 05 Apr 2009, 03:23
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.