Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is what's worked for me:</p> <p>ASM file:</p> <pre><code>; file: blahasm.asm ; assemble with nasm (v 2.10, Mar 12 2012): nasm -f elf32 blahasm.asm -o blahasm.o bits 32 global _blah _blah: mov eax, 42 ret </code></pre> <p>C file:</p> <pre><code>// file: blahc.c // compile with MinGW x86 (gcc v 4.6.2): gcc -Wall -O2 blahc.c blahasm.o -o blah.exe #include &lt;stdio.h&gt; extern int blah(void); int main(void) { printf("blah():%d\n", blah()); return 0; } </code></pre> <p>Output:</p> <pre><code>blah():42 </code></pre> <p>I'm surprised that the only format that's worked is <code>elf32</code> and that it's supported in a Windows port of gcc, which MinGW is.</p> <p><strong>UPDATE</strong>:</p> <p>I've created an assembly-only program with NASM and MinGW.</p> <p>ASM file:</p> <pre><code>; file: nsm.asm ; assemble with NASM (v 2.10, Mar 12 2012): nasm -f elf32 nsm.asm -o nsm.o ; compile (link) with MinGW x86 (gcc v 4.6.2): gcc -Wall -O2 nsm.o -o nsm.exe bits 32 extern ___main extern _printf global _main section .rdata textstr: db "Hello World!", 10, 0 section .text.startup _main: call ___main push textstr call _printf add esp, 4 ret </code></pre> <p>Output:</p> <pre><code>Hello World! </code></pre> <p>I'm running gcc from the "MinGW Shell" (MSYS) and I don't need to specify any additional command line parameters to make the program successfully link with the standard library. And I did not need to do anything special about MinGW and MSYS installation, I think I used all default setup parameters.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload