Assembly programming in Mint

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
turboscrew
Level 4
Level 4
Posts: 222
Joined: Sat Sep 26, 2009 2:13 pm

Assembly programming in Mint

Post by turboscrew »

Didn't come up with any better place to ask this, but:
Does anyone have an idea how Mint handles the command line parameters?

I wrote a small toy program, in AT&T form assembly, and if I compile it with GCC it works fine, but
if I compile it with GAS, the command line parameters are garbage, and the program dies in segmentation fault.

Any pointers to where can I find the righ way to do the command line parameter handling so, that it'd work with GAS too.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
turboscrew
Level 4
Level 4
Posts: 222
Joined: Sat Sep 26, 2009 2:13 pm

Re: Assembly programming in Mint

Post by turboscrew »

Ah, GCC adds a prologue that rearanges the parameters and calls "main".

Code: Select all

# 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"
Locked

Return to “Other topics”