Mail Archives: djgpp/1998/01/08/02:45:20
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 |
---------------------------------------------------------------------
- Raw text -