Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>While <em>@karlphillip</em> method correct in general, you should take in mind some windows specified stuff:</p> <ol> <li><p>While you compile <em>@karlphillip</em>'s code you get linker error produced by <code>MinGw</code> standard library file:</p> <pre><code>c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libmingw32.a(main.o): In function `main': C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to `WinMain@16' </code></pre> <p>That is not your <code>main</code>, that is <code>libmingw32.a</code>'s main. And it expects <code>WinMain</code> as entry point of <em>your</em> code. The thing is that <code>WinMain</code> is default entry point for windows application defined by Microsoft. <code>libmingw32.a</code> defines actual main, that is called from actual entry point. That main does some stuff and than calls <code>WinMain</code>. But you have no <code>WinMain</code> defined, obviously. </p> <p>In this simple example you needn't standard library actually, then you can drop standard library and compile above code with command line</p> <pre><code>gcc -Wl,-subsystem,console 1.S -nostdlib </code></pre> <p>It should be equivalent Qt setting <code>QMAKE_CXXFLAGS+=-nostdlib</code></p> <p>Then code above compiles, and... <em>segfaults</em>. Then go to point 2:</p></li> <li><p><code>int 80h</code> is specific linux system call. Seems it doesn't work on windows. You should invoke <code>WriteConsole</code> on windows to write to <code>stdin</code>. But as a "proof of concept" you can run the following code:</p> <pre><code>.text .globl main main: movl $1, %eax ret </code></pre> <p>This will set exit code of program to 1.</p></li> </ol> <p><strong>EDIT</strong> If you want <em>Hello world</em> example, compiled with standard library included, you can try this:</p> <pre><code>.data hello: .string "Hello World\n" .text .global _WinMain@16 _WinMain@16: push $hello call _puts add $4, %esp ret </code></pre> <p>Compile with <code>gcc 1.S</code></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