RANNA said:
Say the CPU has only AL, BL, CL, DL or eight 8 bit registers, and if
want to declare 10 register variables in my code, is it possible to do
it?
You can declare as many register variables as you want. The compiler is
free to ignore any of those declarations; it's even free to ignore all
of them.
If all 10 variables must exist at the same time, the compiler can't
possibly implement them all as registers on such a machine. However,
keep in mind that the compiler has a lot of freedom to rearrange your
code, so long as the rearranged code has the same behavior as the
original. If it finds a rearrangement such that two of your variables
are never storing a value as the same time, it might implement both of
them as using the same register. If it finds two such pairs, it might be
able to put all ten variables into 8 registers. However, it's more
likely to ignore some or all of your 'register' declarations, and make
up it's own mind about which variables should be stored in registers.
When doing so, it will probably make a better choice than the one that
you made.
If it's really important to you to control such things, the C language
is the wrong one to use. You probably should use some sort of assembly
language.