On Mon, 27 Mar 2000, Chris Fowler wrote:
> I have learned how to program over the years from the application level
> starting with Quick Basic. I would like to learn much more but am not sure
> what books to buy. I know how to write programs and use system calls but I
> want to know how to write what is behind those calls. I would like to start
Chris,
Assuming that you're fairly proficient in C at this point, my
suggestion would be to start by writing small, simple programs in C (like
i = 0;i++;return(i)) , run them through "gcc -S -fverbose-asm", then read
and understand the .s file produced. Start *really simple*, like with a
program which simply returns 0, to get an idea of how the registers are
set up. Then slowly add to the program. Return "1" instead of 0, add an
int variable "i", add 1 to it, etc. As you add new things into your sample
program, you'll see the asm code generated which actually does the work.
Try playing too with gcc's "-O" levels. Start with "-O0" to give a good
idea of what really is going on. ...At the very least, this excersize will
give you a good idea as to how gcc "ticks".
If you are looking to see what is "behind the scenes", of system calls,
then my best suggestion would be to grab the latest stable glibc sources,
as well as linux kernel sources. Untar, then start reading through them.
Another very useful document will be Intel's reference manual for
the x86. I personally have a 386 paperback, but, I'm almost positive that
you can grab a (PDF) reference manual from Intel's site for the CPU of
your choice. This will help you in decifering what some of the asm
instructions really do and really mean. In the manual which I have, the
first few chapters explain the x86 architecture, "protected mode" vs "real
mode", and many other basics. Worth the read (though, I must admit, I've
forgotten a good bit of it now).
Hope this helps,
- Mike
====================================================================
Michael Kachline CS, Georgia Institute of Technlology
">kachline@brightstar.gt.ed.net
http://brightstar.gt.ed.net/kachline
====================================================================
--
To unsubscribe: mail ">majordomo@ale.org with "unsubscribe ale" in message body.