flat assembler
Message board for the users of flat assembler.

Index > Main > extrn question

Author
Thread Post new topic Reply to topic
kamac



Joined: 06 Dec 2013
Posts: 12
kamac 12 Dec 2013, 19:28
Hey there.

I've got a question about extrn. Why do I seem to have to use:
extrn myFunc

rather than:
extrn 'myFunc' as myFunc:dword

When I'm combining two FASM-generated .obj files? I must extern all other functions that seem to come from .a libraries with the 2nd convention, and those that come from .obj files with 1st convention? Is there a way to change that?

Btw. I'm compiling with format MS COFF.

@EDIT

Actually, it does work, but I must call the function this way:
call exportedFunc

rather than this:
call [exportedFunc]

Well, I guess it's mean to be this way. Though, if anybody knows a way to force the call to include [ ], I'd appreciate it.

@EDIT2

Same goes for FASM-generated .a libs. Consider this example:

Code:
format MS COFF
extrn '__imp__printf' as printf:dword

section '.text' code
customFunc:
push dbg
call [printf]
add esp,4
ret    


Then, I generate an .obj file by:
FASM customFunc.asm customFunc.obj

Then, I generate an .a file:
ar rcs libcustomfunc.a customFunc.obj

Then, I must do this to make it work:
Code:
format MS COFF
extrn 'customFunc' as customFunc:dword
section '.text' code
_start:
call customFunc
ret    


Why is that? Why do I have to call printf by using the [ ], and I mustn't use them with my own function taken from shared library?

@nEDIT

Okay, I read this topic:
http://board.flatassembler.net/topic.php?p=108519

And now I kinda understand.. But is there any way for me to declare extern printf and call it without the brackets?
Like:
extrn '__imp__printf' as printf:dword
; ...
call printf

?

Cheers.
Post 12 Dec 2013, 19:28
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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.