Good examples are hard to find.  One approach is to write C
code and then have a peek at what GCC translates it into.
A trivial example might be a file called return1234plus.c
whose entire contents are this:


    unsigned long int
    return1234plus( unsigned long int more )
    {
        return( 1234 + more );
    }


...and if you then say:


    gcc -S -O2 -fomit-frame-pointer return1234plus.c


...you will find the compiler has generated a file
named return1234plus.s that looks like this:


            .file   "return1234plus.c"
            .version        "01.01"
    gcc2_compiled.:
    .text
            .align 4
    .globl return1234plus
            .type    return1234plus,@function
    return1234plus:
            movl 4(%esp),%eax
            addl $1234,%eax
            ret
    .Lfe1:
            .size    return1234plus,.Lfe1-return1234plus
            .ident  "GCC: (GNU) 2.95.4 20010902 (Debian prerelease)"


...which shows (amidst all the glop) how the argument passed
by the caller is copied from the stack to the EAX register
(which is how result values are passed) and 1234 is added to it
before we return to our caller.  There!  Now you're an expert!

Linux kernel source code isn't the greatest, but you can find
some examples of from-scratch assembler code by standing in
a kernel source directory and saying:

    find arch/i386 -name "*.[sS]"

Why are you interested in assembler language?
Did you stop taking your medication again?


*****************************************************************
To unsubscribe from this list, send mail to [EMAIL PROTECTED]
with the text 'unsubscribe gnhlug' in the message body.
*****************************************************************

Reply via email to