LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Assembly programming on Linux? (https://www.linuxquestions.org/questions/programming-9/assembly-programming-on-linux-4175472764/)

turboscrew 08-09-2013 06:53 AM

Assembly programming on Linux?
 
Two questions:

1)
Does anyone know a forum(s) about assembly programming on Linux?
Could be restricted to x86, or non-restricted to Linux.

2)
Why is it that my little assembly program, that uses command line parameters, runs fine if compiled with GCC, but crashes with segmentation fault if compiled wit as and linked with ld?

rtmistler 08-09-2013 09:04 AM

No forum that I know of or can find.

The output of that should be machine instructions, so what I'd do is to compare the output from GCC with the output from AS.

mjolnir 08-09-2013 09:11 AM

http://board.flatassembler.net/topic.php?t=6365

turboscrew 08-09-2013 01:10 PM

Figured the 2) out:
GCC adds a prologue (cinit, I guess) that reorganizes the commandline parameters and calls the "main".
AS doesn't.

Code:

# GCC
# Stack is:
#ESP -> ret addr
#        argc
#        argv -> argv[0] -> "program name"
#                argv[1] -> "Key"
#                argv[2] -> "Infile"
#                argv[3] -> "Outfile"

# GAS
# Stack is:
#ESP -> argc
#        argv[0] -> "program name"
#        argv[1] -> "Key"
#        argv[2] -> "Infile"
#        argv[3] -> "Outfile"



All times are GMT -5. The time now is 01:01 PM.