Why doesn't assembly make output from input? [closed]












3















I have been coding assembly language on my MacOS 10.14. I am using the nasm assembler I got from brew, I am using Macho64, and I coded this script using Linux 32 bit syscalls, but putting 0x200000 before each syscall. I am using the 64 bit registers, %rax, %rdi, %rsi, and %rdx for each syscall and three variables. I have compiled and linked the script, but it does not work, asking for input, but not responding. Here is my code:



global start

section.data

section.bss
var: resb 8

section.text

start:

mov rax, 0x2000003
mov rdi, 0
mov rsi, var
mov rdx, 4
syscall

mov rax, 0x2000004
mov rdi, 1
mov rsi, var
mov rdx, 4
syscall

mov rax, 0x2000001
mov rdi, 0
syscall


I have been unable to find an answer, I have seen this question, but I did not understand the push and pull, and also I am using a pure 64 bit syntax and the question seems to be mainly about matching x86 and x64.










share|improve this question















closed as off-topic by sideshowbarker, M-M, Mike M., Vega, Machavity Jan 30 at 1:13


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – sideshowbarker, M-M, Mike M., Vega, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 1





    Do you get warnings when you assemble this?I ask because after the word section you need a space.

    – Michael Petch
    Jan 20 at 8:55













  • The x64 syscalls are completely different than the 32bit int80 calls. So the mov eax, 0x3 to signify "read a character" to int80 does something entirely different when passed in rax to syscall. And I'm not sure what you think putting 0x2000000 in front of everything is supposed to do, but it's not helping.

    – David Wohlferd
    Jan 20 at 9:22






  • 2





    @DavidWohlferd : because this is for MacOS (BSD) and the system call numbers for 64-bit are the 32-bit MacOS calls with 0x2000000 added.

    – Michael Petch
    Jan 20 at 9:33








  • 1





    Doh! My bad. I'll leave it to show my shame.

    – David Wohlferd
    Jan 20 at 10:04






  • 1





    @MichaelPetch You're actually right, that was the problem, though, it did not return an error, thank you.

    – Murpha Schnee
    Jan 20 at 10:31
















3















I have been coding assembly language on my MacOS 10.14. I am using the nasm assembler I got from brew, I am using Macho64, and I coded this script using Linux 32 bit syscalls, but putting 0x200000 before each syscall. I am using the 64 bit registers, %rax, %rdi, %rsi, and %rdx for each syscall and three variables. I have compiled and linked the script, but it does not work, asking for input, but not responding. Here is my code:



global start

section.data

section.bss
var: resb 8

section.text

start:

mov rax, 0x2000003
mov rdi, 0
mov rsi, var
mov rdx, 4
syscall

mov rax, 0x2000004
mov rdi, 1
mov rsi, var
mov rdx, 4
syscall

mov rax, 0x2000001
mov rdi, 0
syscall


I have been unable to find an answer, I have seen this question, but I did not understand the push and pull, and also I am using a pure 64 bit syntax and the question seems to be mainly about matching x86 and x64.










share|improve this question















closed as off-topic by sideshowbarker, M-M, Mike M., Vega, Machavity Jan 30 at 1:13


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – sideshowbarker, M-M, Mike M., Vega, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 1





    Do you get warnings when you assemble this?I ask because after the word section you need a space.

    – Michael Petch
    Jan 20 at 8:55













  • The x64 syscalls are completely different than the 32bit int80 calls. So the mov eax, 0x3 to signify "read a character" to int80 does something entirely different when passed in rax to syscall. And I'm not sure what you think putting 0x2000000 in front of everything is supposed to do, but it's not helping.

    – David Wohlferd
    Jan 20 at 9:22






  • 2





    @DavidWohlferd : because this is for MacOS (BSD) and the system call numbers for 64-bit are the 32-bit MacOS calls with 0x2000000 added.

    – Michael Petch
    Jan 20 at 9:33








  • 1





    Doh! My bad. I'll leave it to show my shame.

    – David Wohlferd
    Jan 20 at 10:04






  • 1





    @MichaelPetch You're actually right, that was the problem, though, it did not return an error, thank you.

    – Murpha Schnee
    Jan 20 at 10:31














3












3








3








I have been coding assembly language on my MacOS 10.14. I am using the nasm assembler I got from brew, I am using Macho64, and I coded this script using Linux 32 bit syscalls, but putting 0x200000 before each syscall. I am using the 64 bit registers, %rax, %rdi, %rsi, and %rdx for each syscall and three variables. I have compiled and linked the script, but it does not work, asking for input, but not responding. Here is my code:



global start

section.data

section.bss
var: resb 8

section.text

start:

mov rax, 0x2000003
mov rdi, 0
mov rsi, var
mov rdx, 4
syscall

mov rax, 0x2000004
mov rdi, 1
mov rsi, var
mov rdx, 4
syscall

mov rax, 0x2000001
mov rdi, 0
syscall


I have been unable to find an answer, I have seen this question, but I did not understand the push and pull, and also I am using a pure 64 bit syntax and the question seems to be mainly about matching x86 and x64.










share|improve this question
















I have been coding assembly language on my MacOS 10.14. I am using the nasm assembler I got from brew, I am using Macho64, and I coded this script using Linux 32 bit syscalls, but putting 0x200000 before each syscall. I am using the 64 bit registers, %rax, %rdi, %rsi, and %rdx for each syscall and three variables. I have compiled and linked the script, but it does not work, asking for input, but not responding. Here is my code:



global start

section.data

section.bss
var: resb 8

section.text

start:

mov rax, 0x2000003
mov rdi, 0
mov rsi, var
mov rdx, 4
syscall

mov rax, 0x2000004
mov rdi, 1
mov rsi, var
mov rdx, 4
syscall

mov rax, 0x2000001
mov rdi, 0
syscall


I have been unable to find an answer, I have seen this question, but I did not understand the push and pull, and also I am using a pure 64 bit syntax and the question seems to be mainly about matching x86 and x64.







macos assembly nasm x86-64 mach-o






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 20 at 9:38









Michael Petch

25.5k556102




25.5k556102










asked Jan 20 at 4:01









Murpha SchneeMurpha Schnee

494




494




closed as off-topic by sideshowbarker, M-M, Mike M., Vega, Machavity Jan 30 at 1:13


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – sideshowbarker, M-M, Mike M., Vega, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by sideshowbarker, M-M, Mike M., Vega, Machavity Jan 30 at 1:13


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – sideshowbarker, M-M, Mike M., Vega, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1





    Do you get warnings when you assemble this?I ask because after the word section you need a space.

    – Michael Petch
    Jan 20 at 8:55













  • The x64 syscalls are completely different than the 32bit int80 calls. So the mov eax, 0x3 to signify "read a character" to int80 does something entirely different when passed in rax to syscall. And I'm not sure what you think putting 0x2000000 in front of everything is supposed to do, but it's not helping.

    – David Wohlferd
    Jan 20 at 9:22






  • 2





    @DavidWohlferd : because this is for MacOS (BSD) and the system call numbers for 64-bit are the 32-bit MacOS calls with 0x2000000 added.

    – Michael Petch
    Jan 20 at 9:33








  • 1





    Doh! My bad. I'll leave it to show my shame.

    – David Wohlferd
    Jan 20 at 10:04






  • 1





    @MichaelPetch You're actually right, that was the problem, though, it did not return an error, thank you.

    – Murpha Schnee
    Jan 20 at 10:31














  • 1





    Do you get warnings when you assemble this?I ask because after the word section you need a space.

    – Michael Petch
    Jan 20 at 8:55













  • The x64 syscalls are completely different than the 32bit int80 calls. So the mov eax, 0x3 to signify "read a character" to int80 does something entirely different when passed in rax to syscall. And I'm not sure what you think putting 0x2000000 in front of everything is supposed to do, but it's not helping.

    – David Wohlferd
    Jan 20 at 9:22






  • 2





    @DavidWohlferd : because this is for MacOS (BSD) and the system call numbers for 64-bit are the 32-bit MacOS calls with 0x2000000 added.

    – Michael Petch
    Jan 20 at 9:33








  • 1





    Doh! My bad. I'll leave it to show my shame.

    – David Wohlferd
    Jan 20 at 10:04






  • 1





    @MichaelPetch You're actually right, that was the problem, though, it did not return an error, thank you.

    – Murpha Schnee
    Jan 20 at 10:31








1




1





Do you get warnings when you assemble this?I ask because after the word section you need a space.

– Michael Petch
Jan 20 at 8:55







Do you get warnings when you assemble this?I ask because after the word section you need a space.

– Michael Petch
Jan 20 at 8:55















The x64 syscalls are completely different than the 32bit int80 calls. So the mov eax, 0x3 to signify "read a character" to int80 does something entirely different when passed in rax to syscall. And I'm not sure what you think putting 0x2000000 in front of everything is supposed to do, but it's not helping.

– David Wohlferd
Jan 20 at 9:22





The x64 syscalls are completely different than the 32bit int80 calls. So the mov eax, 0x3 to signify "read a character" to int80 does something entirely different when passed in rax to syscall. And I'm not sure what you think putting 0x2000000 in front of everything is supposed to do, but it's not helping.

– David Wohlferd
Jan 20 at 9:22




2




2





@DavidWohlferd : because this is for MacOS (BSD) and the system call numbers for 64-bit are the 32-bit MacOS calls with 0x2000000 added.

– Michael Petch
Jan 20 at 9:33







@DavidWohlferd : because this is for MacOS (BSD) and the system call numbers for 64-bit are the 32-bit MacOS calls with 0x2000000 added.

– Michael Petch
Jan 20 at 9:33






1




1





Doh! My bad. I'll leave it to show my shame.

– David Wohlferd
Jan 20 at 10:04





Doh! My bad. I'll leave it to show my shame.

– David Wohlferd
Jan 20 at 10:04




1




1





@MichaelPetch You're actually right, that was the problem, though, it did not return an error, thank you.

– Murpha Schnee
Jan 20 at 10:31





@MichaelPetch You're actually right, that was the problem, though, it did not return an error, thank you.

– Murpha Schnee
Jan 20 at 10:31












1 Answer
1






active

oldest

votes


















3














I was actually mistaken about the problem, it wasn't a syscall error, but rather a syntax error that did not return the error. The mistake I found out was I had to put a blank space after section, which I didn't. Thank you @Michael Petch for solving this.






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    I was actually mistaken about the problem, it wasn't a syscall error, but rather a syntax error that did not return the error. The mistake I found out was I had to put a blank space after section, which I didn't. Thank you @Michael Petch for solving this.






    share|improve this answer




























      3














      I was actually mistaken about the problem, it wasn't a syscall error, but rather a syntax error that did not return the error. The mistake I found out was I had to put a blank space after section, which I didn't. Thank you @Michael Petch for solving this.






      share|improve this answer


























        3












        3








        3







        I was actually mistaken about the problem, it wasn't a syscall error, but rather a syntax error that did not return the error. The mistake I found out was I had to put a blank space after section, which I didn't. Thank you @Michael Petch for solving this.






        share|improve this answer













        I was actually mistaken about the problem, it wasn't a syscall error, but rather a syntax error that did not return the error. The mistake I found out was I had to put a blank space after section, which I didn't. Thank you @Michael Petch for solving this.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 20 at 10:33









        Murpha SchneeMurpha Schnee

        494




        494















            Popular posts from this blog

            Homophylophilia

            Updating UILabel text programmatically using a function

            Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage