flat assembler
Message board for the users of flat assembler.
Index
> Windows > Coff files, Visual Studio 2008, and MINGW questions. |
Author |
|
vid 08 Oct 2010, 18:02
Not sure what object file MinGW uses. I always thought it uses ELF, but never checked really.
Quote: For MINGW what would the procedure be? Simply add the .o file to command line. |
|||
08 Oct 2010, 18:02 |
|
LocoDelAssembly 08 Oct 2010, 18:06
DarkAlchemist, In the case of VS, using the "Add > Existing Item..." also works and perhaps that's better since you'll also see the file listed in the project explorer.
|
|||
08 Oct 2010, 18:06 |
|
DarkAlchemist 08 Oct 2010, 19:08
Which item do I add as I have yet to see a .coff produced via the FASMW.exe program or do I need another ide?
Funny thing is that I do not even see a way to produce a .o via FASMW.exe. Maybe I am too used to toggles in the ide these days and there is possibly a flag I need to set in the source? |
|||
08 Oct 2010, 19:08 |
|
LocoDelAssembly 08 Oct 2010, 20:04
Here you have a thread related to this: http://board.flatassembler.net/topic.php?t=11984
It is OK to use .OBJ, at least when I've tried (see the thread), it worked and it is a MS COFF. To make FASM create ".o" it is "format ELF" what you have to use. However, if you are trying to force extensions that not match what fasm uses for the target format, then you could use, for instance, "format ms coff as 'coff'" or "format ms coff as 'o'" or "format foo as 'bar'", etc. |
|||
08 Oct 2010, 20:04 |
|
Fanael 08 Oct 2010, 20:12
vid wrote: Not sure what object file MinGW uses. I always thought it uses ELF, but never checked really. |
|||
08 Oct 2010, 20:12 |
|
DarkAlchemist 08 Oct 2010, 22:54
LocoDelAssembly wrote: Here you have a thread related to this: http://board.flatassembler.net/topic.php?t=11984 Code: include 'win32ax.inc' _hello db 'Hello World',0 _title db 'FASM rocks HARD',0 start: invoke MessageBox, NULL, _hello, _title, MB_OK invoke ExitProcess,0 .end start Is there some documentation I can read about what to do when I wish to write a procedure? Something I can understand what it is I need to do and what I am currently doing wrong? |
|||
08 Oct 2010, 22:54 |
|
vid 09 Oct 2010, 11:48
Have you seen my old examples of mixing C and Asm? It worked with Visual C++ (compiler that Visual Studio suite uses), but I never tried to do it directly from IDE. I prefer command line. It has examples of how to write proper procedures which can be called from C/C++ code.
|
|||
09 Oct 2010, 11:48 |
|
DarkAlchemist 09 Oct 2010, 20:45
No, I haven't but I think it would work, it should actually, if I understood FASM better in this regard. I can't even get the simple code I wrote to convert into a procedure then get FASM to output the coff file.
|
|||
09 Oct 2010, 20:45 |
|
rugxulo 11 Oct 2010, 20:17
Take a look here:
http://sites.google.com/site/rugxulo/paq8o8z-Jan13-lite.tgz?attredirects=0 You can use FASM + MinGW (or DJGPP, even). I'm a pretty crappy programmer, but despite that, it seems to work! Trivia: MinGW and Cygwin both output MS COFF for Windows, which is (sadly) incompatible with DJGPP's COFF (relocations?). However, it seems recent versions of GNU ld handle both okay. And I know MinGW and Cygwin ld are each built with ELF support too. But only rare things like Bellard's TinyC (TCC) use ELF there (yes, even on Windows, for object files, but not final .EXEs obviously). Okay, well, DJELF exists too, but nobody [but me] cares, that's DOS. |
|||
11 Oct 2010, 20:17 |
|
DarkAlchemist 11 Oct 2010, 23:25
I downloaded that file and will look it over later, thank you.
edit: This is just some program so what exactly am I supposed to be looking for? Btw, my IDE for MSVC is Visual Studio and WxDevCPP for Mingw. |
|||
11 Oct 2010, 23:25 |
|
rugxulo 12 Oct 2010, 06:29
DarkAlchemist wrote:
Of course it's just "some" program, it's an example of using FASM and G++. See paq8o8z/src/otherasm/fast-paq.fsm . I've used that [sic] to build under Linux, Win32 (MinGW), and DOS (DJGPP). |
|||
12 Oct 2010, 06:29 |
|
DarkAlchemist 12 Oct 2010, 11:17
Well, this is where the problem lies, for me and my lack of understanding:
Code: format ms coff include 'win32ax.inc' _hello db 'Hello World',0 _title db 'FASM rocks HARD',0 start: invoke MessageBox, NULL, _hello, _title, MB_OK invoke ExitProcess,0 .end start So, what am I doing wrong in the above example? |
|||
12 Oct 2010, 11:17 |
|
vid 12 Oct 2010, 15:06
Okay, here's the example how to link with MinGW:
fasmy_proc.asm: Code: format ms coff ;include header usable for COFF include 'win32a.inc' ;declare external proc we use here extrn "_MessageBoxA@16" as MessageBox:dword ;number behind @ is number of arguments times 4 ;"publish" procedure this object provides to other objects public fasmy_proc as "_fasmy_proc@0" section '.data' data readable writeable ;in fact, this should go to "const" read-only section, but nevermind _hello db 'Hello World',0 _title db 'FASM rocks HARD',0 section '.text' code readable executable ;very simple procedure, which doesn't take any arguments ;declare as: void fasmy_proc(); fasmy_proc: ;just display MessageBox ;Note: use "stdcall" for WinAPI procs, not "invoke" ;invoke is only for imports constructed by FASM macros. stdcall MessageBox, NULL, _hello, _title, MB_OK ;return to caller retn test.c: Code: void __stdcall fasmy_proc(); int main() { fasmy_proc(); return 0; } command line: Code: fasm fasmy_proc.asm fasmy_proc.o gcc test.c fasmy_proc.o Things get bit more complicated once you want to pass arguments and return values. |
|||
12 Oct 2010, 15:06 |
|
DarkAlchemist 12 Oct 2010, 15:26
Well, see, the above I mostly understand but so much I do not. I have never linked C/C++ and ASM before and this is why I wanted some really good documentation on what you just did plus this was a simple function but in the real world arguments and return values are needed.
|
|||
12 Oct 2010, 15:26 |
|
baldr 12 Oct 2010, 17:03
DarkAlchemist,
Linker (while I prefer RSTS/E term, «task builder») does quite staightforward job, it starts from object containing entry point (your 2010-10-12 14:17 example won't compile because of entry directive in .end macroinstruction expansion, by the way), adds objects containing names referenced by it (not with PE import directory, but with extrn directive), adds objects containing names referenced by them, adds objects containing names referenced by them, ad infinitum. |
|||
12 Oct 2010, 17:03 |
|
vid 12 Oct 2010, 17:41
DarkAlchemist: okay, then google what you can about "stdcall" and "ccall", and how to write such procs. It's not that hard.
|
|||
12 Oct 2010, 17:41 |
|
f0dder 14 Oct 2010, 02:41
rugxulo wrote: Trivia: MinGW and Cygwin both output MS COFF for Windows, which is (sadly) incompatible with DJGPP's COFF (relocations?). Also iirc mscoff and djgpp-coff use the same magic identifier, so you can't discern between the two? At least I recall running my head against walls many years ago when I tried building bintools for djgpp with both dj- and ms-coff support. I finally did the sane thing and ditched djgpp... if you need C development under DOS, you're probably better off using win32 console apps and a dos extender that can handle those. _________________ - carpe noctem |
|||
14 Oct 2010, 02:41 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.