LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-09-2013, 06:53 AM   #1
turboscrew
Member
 
Registered: Apr 2009
Location: Nokia (town), Finland
Distribution: Mint, Debian
Posts: 601

Rep: Reputation: 46
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?
 
Old 08-09-2013, 09:04 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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.
 
Old 08-09-2013, 01:10 PM   #4
turboscrew
Member
 
Registered: Apr 2009
Location: Nokia (town), Finland
Distribution: Mint, Debian
Posts: 601

Original Poster
Rep: Reputation: 46
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"
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux Assembly Programming Dury03 Programming 3 03-07-2011 02:41 PM
How to start programming assembly in Linux? lowpro2k3 Programming 3 04-05-2005 12:10 AM
x86 assembly programming in Linux XsuX Programming 9 12-01-2004 09:45 AM
assembly programming in linux chriscoelphoto Linux - Newbie 2 05-02-2004 05:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration