LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   seeking docs for system calls in assembler (http://www.linuxquestions.org/questions/programming-9/seeking-docs-for-system-calls-in-assembler-531943/)

dsdarrow 02-24-2007 05:28 AM

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

bigrigdriver 02-24-2007 12:45 PM

Point your browser at www.google.com/linux, and use the search terms: assembler "system calls". I got 47,000 returns.

osor 02-24-2007 01:06 PM

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.

dsdarrow 02-24-2007 07:54 PM

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

osor 02-24-2007 10:12 PM

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?

dsdarrow 02-25-2007 07:15 AM

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

introuble 02-25-2007 01:28 PM

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.

dsdarrow 02-28-2007 06:06 PM

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)

Nick_Battle 03-01-2007 06:54 AM

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.


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