How can I assemble a 64-bit assembly language program in Cygwin under Windows7?How can I set up an editor to work with Git on Windows?How can I develop for iPhone using a Windows development machine?How can you find out which process is listening on a port on Windows?How to navigate to a directory in C: with Cygwin?Avoiding the JMP in the JMP CALL POP technique for shellcode NASM?Assembly Syscalls in 64-bit WindowsAssember prompt for user input doesn't workMemory allocation and addressing in AssemblyNASM x86_64 printf 7th argument

How should I ask for a "pint" in countries that use metric?

Array or vector? Two dimensional array or matrix?

Can the word "desk" be used as a verb?

Clarinets in the Rite of Spring

Is there a formal/better word than "skyrocket" for the given context?

What are the consequences for a developed nation to not accept any refugees?

Tesco's Burger Relish Best Before End date number

US citizen traveling with Peruvian passport

Blocks from @ jafe

Sense of humor in your sci-fi stories

Category-theoretic treatment of diffs, patches and merging?

How does one acquire an undead eyeball encased in a gem?

Mtg creature spells, instants, priority?

What factors could lead to bishops establishing monastic armies?

How can I review my manager, who is fine?

Why am I getting unevenly-spread results when using $RANDOM?

Interpretation of non-significant results as "trends"

Strong Password Detection in Python

Why do people prefer metropolitan areas, considering monsters and villains?

Can a landlord force all residents to use the landlord's in-house debit card accounts?

Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?

Chilling water in copper vessel

Four ships at the ocean with the same distance

Write a function



How can I assemble a 64-bit assembly language program in Cygwin under Windows7?


How can I set up an editor to work with Git on Windows?How can I develop for iPhone using a Windows development machine?How can you find out which process is listening on a port on Windows?How to navigate to a directory in C: with Cygwin?Avoiding the JMP in the JMP CALL POP technique for shellcode NASM?Assembly Syscalls in 64-bit WindowsAssember prompt for user input doesn't workMemory allocation and addressing in AssemblyNASM x86_64 printf 7th argument






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to do assembly programming in Linux using NASM (example). But, I want to avoid installing Linux on my machine. Rather, I have a 64-bit Win7 machine in which Cygwin is installed.



The following is my test program:



section .data
text1 db "What is your name?"
text2 db "Hello "

section .bss
name resb 30

section .text
global start

start:
; display the prompt
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, text1 ; load the address of the variable
mov rdx, 19 ; write sizeof(text1) == 19 bytes
syscall ; tell the processor to accomplish the task

; take input from KB
mov rax, 0 ; specify std in
mov rdi, 0 ; specify read operation
mov rsi, name ; load the address of the variable
mov rdx, 30 ; read sizeof(name) == 30 bytes
syscall ; tell the processor to accomplish the task

; display "Hello "
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, text2 ; load the address of the variable
mov rdx, 7 ; write sizeof(text2) == 7 bytes
syscall ; tell the processor to accomplish the task

; display 'name'
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, name ; load the address of the variable
mov rdx, 30 ; write sizeof(name) == 30 bytes
syscall ; tell the processor to accomplish the task

; terminate program
mov rax, 60 ; specify program termination
mov rdi, 0 ; return without error
syscall


The following is my assembly command and output:



Acer@Acer-PC ~
$ nasm -f elf64 name_io.asm -o name_io.o

Acer@Acer-PC ~
$ ld name_io.o -o name_io.exe

Acer@Acer-PC ~
$ ./name_io
Illegal instruction

Acer@Acer-PC ~
$


The source code is being assembled, but it is not executing.



What can I do to properly assemble and run a Linux-assembly program in Cygwin+Windows?










share|improve this question



















  • 2





    You created a 64 bit program all right, but the code you used is for linux. That will not work on windows. cygwin does not emulate syscall. You need to use the POSIX functions instead.

    – Jester
    Mar 25 at 22:33







  • 1





    Or use Windows Subsystem for Linux to get a Windows kernel layer that supports x86-64 Linux system calls. IDK if you can install a bare-bones version of this that provides just the kernel side without much or any user-space.

    – Peter Cordes
    Mar 25 at 23:37












  • Possible duplicate of Assembly Syscalls in 64-bit Windows but it doesn't fit perfectly, the answer doesn't directly address cygwin only emulating a POSIX environment via library function calls, definitely not Linux system calls.

    – Peter Cordes
    Mar 26 at 0:03






  • 1





    Windows 7 doesn't have WSL.

    – Michael Petch
    Mar 26 at 0:12











  • You could install a Linux VM, e.g. in VirtualBox (or VMWare or Parallels). That is quite easy and they often come pre-packaged. Just download and start with VirtualBox.

    – Rudy Velthuis
    Mar 27 at 10:20

















0















I want to do assembly programming in Linux using NASM (example). But, I want to avoid installing Linux on my machine. Rather, I have a 64-bit Win7 machine in which Cygwin is installed.



The following is my test program:



section .data
text1 db "What is your name?"
text2 db "Hello "

section .bss
name resb 30

section .text
global start

start:
; display the prompt
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, text1 ; load the address of the variable
mov rdx, 19 ; write sizeof(text1) == 19 bytes
syscall ; tell the processor to accomplish the task

; take input from KB
mov rax, 0 ; specify std in
mov rdi, 0 ; specify read operation
mov rsi, name ; load the address of the variable
mov rdx, 30 ; read sizeof(name) == 30 bytes
syscall ; tell the processor to accomplish the task

; display "Hello "
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, text2 ; load the address of the variable
mov rdx, 7 ; write sizeof(text2) == 7 bytes
syscall ; tell the processor to accomplish the task

; display 'name'
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, name ; load the address of the variable
mov rdx, 30 ; write sizeof(name) == 30 bytes
syscall ; tell the processor to accomplish the task

; terminate program
mov rax, 60 ; specify program termination
mov rdi, 0 ; return without error
syscall


The following is my assembly command and output:



Acer@Acer-PC ~
$ nasm -f elf64 name_io.asm -o name_io.o

Acer@Acer-PC ~
$ ld name_io.o -o name_io.exe

Acer@Acer-PC ~
$ ./name_io
Illegal instruction

Acer@Acer-PC ~
$


The source code is being assembled, but it is not executing.



What can I do to properly assemble and run a Linux-assembly program in Cygwin+Windows?










share|improve this question



















  • 2





    You created a 64 bit program all right, but the code you used is for linux. That will not work on windows. cygwin does not emulate syscall. You need to use the POSIX functions instead.

    – Jester
    Mar 25 at 22:33







  • 1





    Or use Windows Subsystem for Linux to get a Windows kernel layer that supports x86-64 Linux system calls. IDK if you can install a bare-bones version of this that provides just the kernel side without much or any user-space.

    – Peter Cordes
    Mar 25 at 23:37












  • Possible duplicate of Assembly Syscalls in 64-bit Windows but it doesn't fit perfectly, the answer doesn't directly address cygwin only emulating a POSIX environment via library function calls, definitely not Linux system calls.

    – Peter Cordes
    Mar 26 at 0:03






  • 1





    Windows 7 doesn't have WSL.

    – Michael Petch
    Mar 26 at 0:12











  • You could install a Linux VM, e.g. in VirtualBox (or VMWare or Parallels). That is quite easy and they often come pre-packaged. Just download and start with VirtualBox.

    – Rudy Velthuis
    Mar 27 at 10:20













0












0








0








I want to do assembly programming in Linux using NASM (example). But, I want to avoid installing Linux on my machine. Rather, I have a 64-bit Win7 machine in which Cygwin is installed.



The following is my test program:



section .data
text1 db "What is your name?"
text2 db "Hello "

section .bss
name resb 30

section .text
global start

start:
; display the prompt
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, text1 ; load the address of the variable
mov rdx, 19 ; write sizeof(text1) == 19 bytes
syscall ; tell the processor to accomplish the task

; take input from KB
mov rax, 0 ; specify std in
mov rdi, 0 ; specify read operation
mov rsi, name ; load the address of the variable
mov rdx, 30 ; read sizeof(name) == 30 bytes
syscall ; tell the processor to accomplish the task

; display "Hello "
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, text2 ; load the address of the variable
mov rdx, 7 ; write sizeof(text2) == 7 bytes
syscall ; tell the processor to accomplish the task

; display 'name'
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, name ; load the address of the variable
mov rdx, 30 ; write sizeof(name) == 30 bytes
syscall ; tell the processor to accomplish the task

; terminate program
mov rax, 60 ; specify program termination
mov rdi, 0 ; return without error
syscall


The following is my assembly command and output:



Acer@Acer-PC ~
$ nasm -f elf64 name_io.asm -o name_io.o

Acer@Acer-PC ~
$ ld name_io.o -o name_io.exe

Acer@Acer-PC ~
$ ./name_io
Illegal instruction

Acer@Acer-PC ~
$


The source code is being assembled, but it is not executing.



What can I do to properly assemble and run a Linux-assembly program in Cygwin+Windows?










share|improve this question
















I want to do assembly programming in Linux using NASM (example). But, I want to avoid installing Linux on my machine. Rather, I have a 64-bit Win7 machine in which Cygwin is installed.



The following is my test program:



section .data
text1 db "What is your name?"
text2 db "Hello "

section .bss
name resb 30

section .text
global start

start:
; display the prompt
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, text1 ; load the address of the variable
mov rdx, 19 ; write sizeof(text1) == 19 bytes
syscall ; tell the processor to accomplish the task

; take input from KB
mov rax, 0 ; specify std in
mov rdi, 0 ; specify read operation
mov rsi, name ; load the address of the variable
mov rdx, 30 ; read sizeof(name) == 30 bytes
syscall ; tell the processor to accomplish the task

; display "Hello "
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, text2 ; load the address of the variable
mov rdx, 7 ; write sizeof(text2) == 7 bytes
syscall ; tell the processor to accomplish the task

; display 'name'
mov rax, 1 ; specify std out
mov rdi, 1 ; specify write opeartion
mov rsi, name ; load the address of the variable
mov rdx, 30 ; write sizeof(name) == 30 bytes
syscall ; tell the processor to accomplish the task

; terminate program
mov rax, 60 ; specify program termination
mov rdi, 0 ; return without error
syscall


The following is my assembly command and output:



Acer@Acer-PC ~
$ nasm -f elf64 name_io.asm -o name_io.o

Acer@Acer-PC ~
$ ld name_io.o -o name_io.exe

Acer@Acer-PC ~
$ ./name_io
Illegal instruction

Acer@Acer-PC ~
$


The source code is being assembled, but it is not executing.



What can I do to properly assemble and run a Linux-assembly program in Cygwin+Windows?







windows assembly cygwin x86-64 nasm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 23:37









Peter Cordes

147k21 gold badges233 silver badges377 bronze badges




147k21 gold badges233 silver badges377 bronze badges










asked Mar 25 at 22:26









user366312user366312

4,08847 gold badges162 silver badges321 bronze badges




4,08847 gold badges162 silver badges321 bronze badges







  • 2





    You created a 64 bit program all right, but the code you used is for linux. That will not work on windows. cygwin does not emulate syscall. You need to use the POSIX functions instead.

    – Jester
    Mar 25 at 22:33







  • 1





    Or use Windows Subsystem for Linux to get a Windows kernel layer that supports x86-64 Linux system calls. IDK if you can install a bare-bones version of this that provides just the kernel side without much or any user-space.

    – Peter Cordes
    Mar 25 at 23:37












  • Possible duplicate of Assembly Syscalls in 64-bit Windows but it doesn't fit perfectly, the answer doesn't directly address cygwin only emulating a POSIX environment via library function calls, definitely not Linux system calls.

    – Peter Cordes
    Mar 26 at 0:03






  • 1





    Windows 7 doesn't have WSL.

    – Michael Petch
    Mar 26 at 0:12











  • You could install a Linux VM, e.g. in VirtualBox (or VMWare or Parallels). That is quite easy and they often come pre-packaged. Just download and start with VirtualBox.

    – Rudy Velthuis
    Mar 27 at 10:20












  • 2





    You created a 64 bit program all right, but the code you used is for linux. That will not work on windows. cygwin does not emulate syscall. You need to use the POSIX functions instead.

    – Jester
    Mar 25 at 22:33







  • 1





    Or use Windows Subsystem for Linux to get a Windows kernel layer that supports x86-64 Linux system calls. IDK if you can install a bare-bones version of this that provides just the kernel side without much or any user-space.

    – Peter Cordes
    Mar 25 at 23:37












  • Possible duplicate of Assembly Syscalls in 64-bit Windows but it doesn't fit perfectly, the answer doesn't directly address cygwin only emulating a POSIX environment via library function calls, definitely not Linux system calls.

    – Peter Cordes
    Mar 26 at 0:03






  • 1





    Windows 7 doesn't have WSL.

    – Michael Petch
    Mar 26 at 0:12











  • You could install a Linux VM, e.g. in VirtualBox (or VMWare or Parallels). That is quite easy and they often come pre-packaged. Just download and start with VirtualBox.

    – Rudy Velthuis
    Mar 27 at 10:20







2




2





You created a 64 bit program all right, but the code you used is for linux. That will not work on windows. cygwin does not emulate syscall. You need to use the POSIX functions instead.

– Jester
Mar 25 at 22:33






You created a 64 bit program all right, but the code you used is for linux. That will not work on windows. cygwin does not emulate syscall. You need to use the POSIX functions instead.

– Jester
Mar 25 at 22:33





1




1





Or use Windows Subsystem for Linux to get a Windows kernel layer that supports x86-64 Linux system calls. IDK if you can install a bare-bones version of this that provides just the kernel side without much or any user-space.

– Peter Cordes
Mar 25 at 23:37






Or use Windows Subsystem for Linux to get a Windows kernel layer that supports x86-64 Linux system calls. IDK if you can install a bare-bones version of this that provides just the kernel side without much or any user-space.

– Peter Cordes
Mar 25 at 23:37














Possible duplicate of Assembly Syscalls in 64-bit Windows but it doesn't fit perfectly, the answer doesn't directly address cygwin only emulating a POSIX environment via library function calls, definitely not Linux system calls.

– Peter Cordes
Mar 26 at 0:03





Possible duplicate of Assembly Syscalls in 64-bit Windows but it doesn't fit perfectly, the answer doesn't directly address cygwin only emulating a POSIX environment via library function calls, definitely not Linux system calls.

– Peter Cordes
Mar 26 at 0:03




1




1





Windows 7 doesn't have WSL.

– Michael Petch
Mar 26 at 0:12





Windows 7 doesn't have WSL.

– Michael Petch
Mar 26 at 0:12













You could install a Linux VM, e.g. in VirtualBox (or VMWare or Parallels). That is quite easy and they often come pre-packaged. Just download and start with VirtualBox.

– Rudy Velthuis
Mar 27 at 10:20





You could install a Linux VM, e.g. in VirtualBox (or VMWare or Parallels). That is quite easy and they often come pre-packaged. Just download and start with VirtualBox.

– Rudy Velthuis
Mar 27 at 10:20












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347297%2fhow-can-i-assemble-a-64-bit-assembly-language-program-in-cygwin-under-windows7%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347297%2fhow-can-i-assemble-a-64-bit-assembly-language-program-in-cygwin-under-windows7%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript