Michael's comment does correctly define the problem. But as an explanation, it is a little thin. So...
While syscall
is the way for a user-mode application (user-mode: if you are not writing a device driver or changing the operating system's kernel, you are writing user-mode) to ask an x64 operating system to do something for you, every x64 OS has slightly different format for making the request.
For example, in the code you posted, you move the value 1 into the eax register. Why do you do that? Why 1 instead of (say) 23? The answer is that on Linux, eax is used to hold a number that tells what operation you want the OS to do. 1 means output string. Then you have to put specific values in other specific registers to say what you want to print and where you want to print it.
But which values you need to set and where they need to go is defined by the people who wrote Linux. Windows can (and does) do things entirely differently: different values, different registers, etc.
So the reason this code doesn't work is that it was designed specifically for Linux and you are trying to run it on Windows. And while cygwin can make things look more linux-like (for example making a command prompt that handles rm
commands), it can't change what happens when you directly invoke the operating system via syscall. You are still running Windows, and that's who is going to handle the syscall. There's nothing cygwin can do about that.
So, with all this in mind, how do you make this code work under Windows? The short answer is that you can't. Microsoft doesn't publish the syscall numbers and what values go in which registers.
If you want to print something under Windows, you are going to need to call a system dll which does all that for you. You can either call ntdll.dll, or some other dll (like msvcrt.dll) which in turn ends up calling ntdll.dll.
There's some good examples at How to write hello world in assembler under Windows?
PS If you find the guy who originally wrote that asm, tell him that while it works on Linux, it is horribly inefficient.