title: Running linked C object files(compiled from C and x86-64 assembly) on Cygwin shell, no output?
body: <p>Trying to deal with my assignment of Assembly Language...</p>
  
  <p>There are two files, hello.c and world.asm, the professor ask us to compile the two file using gcc and nasm and link the object code together. </p>
  
  <p>I can do it under 64 bit ubuntu 12.10 well, with native gcc and nasm.</p>
  
  <p>But when I try same thing on 64 bit Win8 via cygwin 1.7 (first I try to use gcc but somehow the -m64 option doesn't work, and since the professor ask us to generate the code in 64-bit, I googled and found a package called mingw-w64 which has a compiler x86_64-w64-mingw32-gcc that I can use -m64 with), I can get the files compiled to mainhello.o and world.o and link them to a main.out file, but somehow when I type " ./main.out" and wait for the "Hello world", nothing happens, no output no error message.</p>
  
  <p>New user thus can't post image, sorry about that, here is the screenshot of what happens in the Cygwin shell:</p>
  
  <p><img src="https://i.stack.imgur.com/5PJFz.png" alt="enter image description here"></p>
  
  <p>I'm just a newbie to everything, I know I can do the assignment under ubuntu, but I'm just being curious about what's going on here?</p>
  
  <p>Thank you guys</p>
  
  <p>hello.c</p>
  
  <pre><code>//Purpose:  Demonstrate outputting integer data using the format specifiers of C.
  //
  //Compile this source file:     gcc -c -Wall -m64 -o mainhello.o     hello.c
  //Link this object file with all other object files:  
  //gcc -m64 -o main.out mainhello.o world.o
  //Execute in 64-bit protected mode:  ./main.out
  //
  
  #include &lt;stdio.h&gt;
  #include &lt;stdint.h&gt; //For C99 compatability
  
  extern unsigned long int sayhello();
  
  int main(int argc, char* argv[])
  {unsigned long int result = -999;
   printf("%s\n\n","The main C program will now call the X86-64 subprogram.");
   result = sayhello();
   printf("%s\n","The subprogram has returned control to main.");
   printf("%s%lu\n","The return code is ",result);
   printf("%s\n","Bye");
   return result;
  }
  </code></pre>
  
  <p>world.asm</p>
  
  <pre><code>;Purpose:  Output the famous Hello World message.
  
  
  ;Assemble: nasm -f elf64 -l world.lis -o world.o world.asm
  
  
  ;===== Begin code area 
  
  extern printf    ;This function will be linked into the executable by the linker
  
  global sayhello
  
  segment .data    ;Place initialized data in this segment
  
            welcome db "Hello World", 10, 0
            specifierforstringdata db "%s", 10,
  
  
  segment .bss    
  
  segment .text   
  
  sayhello:        
  
  ;Output the famous message
  mov qword rax, 0       
  mov       rdi, specifierforstringdata
  mov       rsi, welcome
  call      printf
  
  ;Prepare to exit from this function
  mov qword rax, 0                                  
  ret;                                              
  
  ;===== End of function sayhello     
  </code></pre>