Linux, NASM 
Author Message
 Linux, NASM

I am trying to find a resource for programming on Linux using NASM.  I have
found the system sources such as "unistd.h" that show some interrupt numbers
but I cannot gather enough
information to use it.  Is there someplace that explains interrupts for
Linux with NASM?

    Thanks!
    John Smith



Tue, 25 Sep 2001 03:00:00 GMT  
 Linux, NASM
Quote:

> I am trying to find a resource for programming on Linux using NASM.  I have
> found the system sources such as "unistd.h" that show some interrupt numbers
> but I cannot gather enough
> information to use it.  Is there someplace that explains interrupts for
> Linux with NASM?

if i were you i'd use libc to interface with system, but if you want all
interrupts and stuff read glibc sources (available from nearest GNU mirror)
Quote:
>     Thanks!
>     John Smith

dominik behr



Tue, 25 Sep 2001 03:00:00 GMT  
 Linux, NASM

Quote:

> I am trying to find a resource for programming on Linux using NASM.  I have
> found the system sources such as "unistd.h" that show some interrupt numbers
> but I cannot gather enough
> information to use it.  Is there someplace that explains interrupts for
> Linux with NASM?

No.  (I searched for a long, long time, that's what I came up with.)

I don't understand how the answer can be no,
but that's what I came up with.
I wish someone would prove me wrong.

Best you can do is read the source code for libc, provided you know C.
If you don't know C, you'll have to learn C.  Personally, I'd rather
deal with they stupididty of DOS.  Linux is nice, but I don't think
it's worth having to learn a language I really don't like well enough
to be able to read other people's source code, and then compile my own
list of interrupt calls, probably making a few mistakes along the way,
adding a week or two to the already way too long process.

I can't believe that't there's not so much as a copy of a text file someone
typed notes into while they were writing the kernel code.  I don't
understand how libc ever got written without any documentation to look at.
If they didn't have any documentation, surely they would have taken some
notes so that they wouldn't have to refer to the kernel source every time
they needed to know how to call a function.

Please let me know if you come up with anything.  Until then, I'll be in
DOS where I'm allowed to program in assembly language.



Fri, 28 Sep 2001 03:00:00 GMT  
 Linux, NASM

says...

[ is there info available on interrupt usage under Linux ]

Quote:
> No.  (I searched for a long, long time, that's what I came up with.)

One of the HowTo files describes the usage of interrupts under Linux.

The basic fact is, you generally do NOT want to use interrupts
directly under Linux, or nearly any other real operating system.  
Linux, Windows NT, OS/2, etc., generally each use ONE interrupt to
transfer control from user mode to kernel mode.  As a rule, they
intentionally leave the parameters and such largely undocumented so
they can modify parameter passing and such at will.

The real question is why you think you should use interrupts instead
of function calls.  Some of the function calls get turned into
interrupts for you, and others get executed entirely in user-mode.  By
using interrupts directly, you 1) compromise the OS's ability to
modify the kernel calling convention for greater efficiency, 2)
compromise the OSes ability to move things into user-mode for greater
efficiency, 3) make your code less readable, and 4) eliminated your
program's ability to execute routines that are already in user mode.

In return for these disadvantages, you gain...well, absolutely NOTHING
that I can think of right now.  I suppose it's _barely_ possible that
once in a great while you'll save a cycle or two in putting the
parameters into the correct registers before the interrupt, but unless
you keep close track of what's available in user-mode, and make good
use of it as well, you're almost certainly looking at a net loss.  
Worse yet, you're looking at a ring switch anyway, so the handful of
cycles you might occasionally save is rarely (if ever) going to amount
to more than a couple of percent in speed.



Fri, 28 Sep 2001 03:00:00 GMT  
 Linux, NASM

Quote:

> I am trying to find a resource for programming on Linux using NASM.  I have
> found the system sources such as "unistd.h" that show some interrupt numbers
> but I cannot gather enough
> information to use it.  Is there someplace that explains interrupts for
> Linux with NASM?

[see http://www.multimania.com/duncan/code/asm/linux/codump.tar.gz]

Well, it's not an HOWTO .. but not that long ago, I wrote a shellcode
and I extended the program so that it dumps code in a C char data format.
Anyway, for the fun of coding, I've done few other examples which may be
helpful. These examples are:

 - chmod.asm     : chmods /bin/sh 04777
 - crashi586.asm : crash a non patched intel pentium
 - dumpcmos.asm  : dump the cmos chipset memory
 - dumpfile.asm  : display /etc/shadow to screen
 - execfile.asm  : spawn a shell
 - getuid.asm    : print uid of user on screen
 - readexec.asm  : allocate 4096b, read code from a file, and execute it
 - rebootsys.asm : sync disk(s) and do a hard reboot
 - shellport.asm : bind a '/bin/sh' shell on port 2727
 - writefile.asm  : add root user 'prout' to /etc/passwd

Of course, it needs nasm 0.97 and it has been tested on linux (up to 2.0.36).
And yeah, no warranty.. and I'm not responsible for any damages which may
caused by it.

                                                        ga



Sun, 14 Oct 2001 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Ploting a pixel under linux with NASM

2. "Hello world"--with tacos--in NASM under Linux

3. Hello World (or anything) with NASM in Linux

4. "Hello world!" with Nasm under Linux

5. NASM in Linux

6. NASM for Linux

7. 3Dnow! Athlon extensions under nasm (linux)

8. Help: linking assembler programs (nasm, linux)

9. nasm, linux, and glibc

10. "hello world" for nasm (linux)

11. NASM (and Linux) beginner

12. Calling printf from NASM under Linux

 

 
Powered by phpBB® Forum Software