LinuxQuestions.org
Review your favorite Linux distribution.
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 01-20-2004, 06:49 PM   #1
Creep
LQ Newbie
 
Registered: Dec 2002
Distribution: Gentoo & Debian
Posts: 25

Rep: Reputation: 15
Linux assembly


Hi, I've been wanting to learn how to write simple programs and library-like functions in assembly for a while, and now when I have some time to spare I thought I'd get to it. I have decided to use Gas as my assembler (don't try to talk me into using nasm. it won't work) and to work in the Linux environment. A few example programs have been written to understand the concept of basic looping and such, but now I've struck an obstacle. From what I can understand, I can't use processor interrupts since Linux runs in protected mode, so I have to use Linux syscalls. My problem is that the few tables of the available syscalls out there doesn't really explain (think novice tutorials...) exactly what type of values to put in which registers etc. I could translate it all from the manpages using my limited skills in C, but in the end all code ends up segfaulting on me, so now I'm wondering if any of you know of a site with info like this. Preferably in AT&T-syntax, but not necessary. I have visited most basic Linux assembly sites, but I probably havn't looked hard enough, because by the looks of it, the threshold to Linux assembly programming seems pretty high. If any of you could please help me find the information I need (or provide a bit of help) I'd be very grateful.
 
Old 01-20-2004, 06:51 PM   #2
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 46
http://cs.nyu.edu/courses/spring03/G...mbly_howto.txt

hope that helps.
 
Old 01-20-2004, 06:58 PM   #3
Creep
LQ Newbie
 
Registered: Dec 2002
Distribution: Gentoo & Debian
Posts: 25

Original Poster
Rep: Reputation: 15
As I said, I have checked out the most basic websites and such, and I've read a few howtos and tutorials too. What I need is a table or tutorial which describes how to use all the Linux syscalls.

Thanks anyway for taking your time though.
 
Old 01-20-2004, 07:02 PM   #4
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 46
oops, sorry. i've been on some kinda posting spree out here. should stop.
 
Old 01-20-2004, 07:35 PM   #5
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
syscall number goes in eax, if there are <= 5 args they go in ebx, ecx, edx, esi, edi in taht order, >= 6 args the args get pushed onto the stack and the pointer to them goes in ebx. for a cool tutorial, see here:
http://www.linuxassembly.org/article....html#Syscalls

for something funny i wrote, a bash like command shell written in pure assembly see here:
http://www.1nfamus.netfirms.com/#asm_shell

and the file /usr/include/asm/unistd.h has all the names and numbers.

Last edited by infamous41md; 01-20-2004 at 09:46 PM.
 
Old 01-20-2004, 07:59 PM   #6
krajzega
Member
 
Registered: Jan 2004
Location: Poland
Distribution: FreeBSD 5.1
Posts: 92

Rep: Reputation: 15
Syscalls in linux are simply functions, which you can read about in manual pages. The whole list of syscalls is placed here:
http://www.linuxhq.com/guides/LPG/no...00000000000000

PS.
IMO, the best way to start programming in Linux is Linux Programmers Guide, which is translated to a few languages
 
Old 01-20-2004, 11:46 PM   #7
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
You know I really recommend going with NASM inste....... ok ok, I am kidding.
 
Old 01-21-2004, 02:53 AM   #8
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
there is this book...free...art of assembly by randall hyde ...
a great book for linux assembly coding..
http://webster.cs.ucr.edu/
as for how to use the system calls ....


there is a doc.
kernel module hacking that tells how you can hijack the system calls with your own calls
http://packetstormsecurity.nl/docs/h...M_HACKING.html

and then, there is nothing like going through the kernel code to see how you can use the system calls.. interrupt 0x80 being raised and context switchin to kernel mode and so on...
 
Old 01-29-2004, 04:40 AM   #10
jinksys
Member
 
Registered: Aug 2003
Location: 63123
Distribution: OpenSuSE/Ubuntu
Posts: 419

Rep: Reputation: 35
if you want to learn true assembly, i'd recommend grabbing Dr Carter's assembly book in pdf form at http://www.drpaulcarter.com/pcasm/. Also, check out the programming guides from intel, available at:
http://developer.intel.com/design/p...uals/245470.htm
http://developer.intel.com/design/p...uals/245471.htm
http://developer.intel.com/design/p...uals/245472.htm
http://www.intel.com/cd/ids/develop...rence/index.htm
 
  


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
Assembly on Linux asahlot Programming 2 11-12-2005 01:04 AM
64-bit Assembly Compiler for Linux? ace_bandit_1 Linux - Software 1 05-13-2005 03:52 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:38 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