From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: 'Register' in C Date: Wed, 07 Jan 1998 19:34:48 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 33 Message-ID: <34B41F28.37FF@cs.com> References: <01bd1ae1$2f536440$d83d63c3 AT default> <34B29809 DOT 8841108D AT pentek DOT com> <34B2AEDA DOT B0D341BD AT pentek DOT com> <34B2E35C DOT 158B21F AT alcyone DOT com> <34B38BB5 DOT 6090 AT nortel DOT ca> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp217.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Ian Chapman wrote: > > so after all this c stuff you have put a pointer into a HW register !!! > any idea which one? If you are to use a pointer effectively you must > know the m/c details and use a pointer reg not an index or accumulator > or link or whatever they have from z80 to cray 2 processor. Regards > Ian. You are, more or less, completely wrong. :-) It is the compiler's responsibility to keep track of which variables are stored in registers at any given time; the programmer should have no need nor desire to know whether "bufptr" is stored in %eax, %ebx, %ecx, or whatever. The reason you put variables in registers is to improve access speed; loading the value from memory each time you want to work with it is a lot slower than keeping it in a register. The compiler is also smart enough to know to put the value back where it belongs when it's done with it. The only reason to use the 'register' storage classifier is when you want to "suggest" to the compiler that it might want to look extra hard at putting a certain variable into a register. It is not required to do so if it feels that it wouldn't work out. If you compile with optimizations, it puts things into registers anyway. Note that registers are four bytes only; it's ridiculous to try to put an entire array into one. -- --------------------------------------------------------------------- | John M. Aldrich | "Sex should be friendly. Otherwise | | aka Fighteer I | stick to mechanical toys; it's more | | mailto:fighteer AT cs DOT com | sanitary." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------