LinuxQuestions.org
Visit Jeremy's Blog.
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 02-24-2007, 05:28 AM   #1
dsdarrow
LQ Newbie
 
Registered: Oct 2006
Posts: 8

Rep: Reputation: 0
seeking docs for system calls in assembler


Hi All,
I'm learning Assembly Language ( or rather RE-learning it as I did some asm programming about 17 yrs ago - on DOS!) using NASM in Linux. What I'm looking for is documentation on the system calls and c calls under Linux. I've found some little documentation on linuxassembly.org and links from there but nearly everything points back at the .c source listings for my system. Trouble is, the sources were not installed on my system. (Ubuntu Edgy Eft) /usr/src/ (which is supposedly the usual location of the source files) contains only the .h header files. Anyone got any idea where I can find documentation for this stuff? What little I HAVE found is for the 2.2 kernel and most of the Linux world is up to 2.4 or 2.6
tia for any help.
-Doug
 
Old 02-24-2007, 12:45 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,770

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Point your browser at www.google.com/linux, and use the search terms: assembler "system calls". I got 47,000 returns.
 
Old 02-24-2007, 01:06 PM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
The system calls and their respective numbers are located in the header file <asm/unistd.h> (/usr/include/asm/unistd.h or /usr/src/linux/include/asm/unistd.h). The documentation for these system calls should be in system calls manpages (category 2).

E.g., for i386, the system call for read is 3 (__NR_read is defined as 3). To find documentation for it, type in terminal “man 2 read” and in the synopsis, it shows the first argument is the file descriptor, the second argument is the buffer into which you read, and the third argument is the number of bytes to be read. For i386, the syscall number should be put in the register eax, the various arguments should be put into the registers ebx, ecx, and edx respectively, and after making the system call (interrupt 0x80), the return value will be in eax.
 
Old 02-24-2007, 07:54 PM   #4
dsdarrow
LQ Newbie
 
Registered: Oct 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Thnx for our reply, osor -

I haave managed to locate the actual call nums in the .h files but I've got several listins of those call numbers. The problem is I have nothing listing what args a supposed to be passed where. This is supposed to be docuemented in the actual .c source files and I don't have the .c sources.

And, yes I've already tried Googleing for the sys calls but they all point back at the source files. ( at least all that I've checked out. I haven't checked them all yet)

Thanx for the replies though. I'll keep trying.
-Doug
 
Old 02-24-2007, 10:12 PM   #5
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Quote:
Originally Posted by dsdarrow
Thnx for our reply, osor -

I haave managed to locate the actual call nums in the .h files but I've got several listins of those call numbers. The problem is I have nothing listing what args a supposed to be passed where. This is supposed to be docuemented in the actual .c source files and I don't have the .c sources.

And, yes I've already tried Googleing for the sys calls but they all point back at the source files. ( at least all that I've checked out. I haven't checked them all yet)

Thanx for the replies though. I'll keep trying.
-Doug
Do you have the section 2 manpages?
 
Old 02-25-2007, 07:15 AM   #6
dsdarrow
LQ Newbie
 
Registered: Oct 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by osor
Do you have the section 2 manpages?
Hi,osor-
to answer your last Q, no I don't have the section 2 man pages. I managed to locate and install the kernel sources. This is a help because with careful reading I can gain some understand of what the calls are doing, but my knowledge of c is rudimentary at best so it's rather slow going.

Do the man pages offer a better/more understandable explanation of what's needed for the sys_calls? If so, where can I get these man pages?

Thanx again
-Doug
 
Old 02-25-2007, 01:28 PM   #7
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Rep: Reputation: 31
I'd install the following:

Code:
manpages
manpages-dev
manpages-posix
manpages-posix-dev
You need the multiverse rep. for some of the above, see packages.ubuntu.com for details.
 
Old 02-28-2007, 06:06 PM   #8
dsdarrow
LQ Newbie
 
Registered: Oct 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by introuble
I'd install the following:

Code:
manpages
manpages-dev
manpages-posix
manpages-posix-dev
You need the multiverse rep. for some of the above, see packages.ubuntu.com for details.
Thanks, I'm installing them now as we speak (er..sort-of)
 
Old 03-01-2007, 06:54 AM   #9
Nick_Battle
Member
 
Registered: Dec 2006
Location: Bracknell, UK
Distribution: SUSE 13.1
Posts: 159

Rep: Reputation: 32
You might find these links useful:

http://lxr.linux.no/source/include/a...std.h?v=2.6.18
http://lxr.linux.no/source/include/l...lls.h?v=2.6.18
http://lxr.linux.no/source/fs/read_write.c?v=2.6.18

The first two give you the syscall numbers and prototypes. The system calls themselves seem to be spread round the kernel (presumably in the relevant subsystems) - the third file is an example for read(2) and write(2), which are called sys_read() and sys_write() in the kernel.

The site indexes and hyperlinks the whole kernel source, so you can browse it easily (only up to version 2.6.18 at the moment).

HTH.
 
  


Reply

Tags
assembler, assembly, calls, language, man, pages, system


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
shell example using system calls djgerbavore Programming 7 03-06-2010 02:39 AM
how do you use system calls? slinky2004 General 1 12-22-2005 09:39 PM
modifying system calls manjiri Linux - Newbie 3 11-07-2005 01:02 PM
Some system calls Spooky Programming 1 11-24-2004 10:17 AM
System Attacks Docs enigma82 Linux - Security 2 11-02-2004 08:26 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration