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? 7 1846
RANNA wrote:
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.
RANNA wrote:
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?
Yes. Declare a hundred if you like, or a thousand.
But it probably won't do you any good. Declaring a variable with
the `register' storage class does two things: It prevents you from
forming any pointers to the variable, and it suggests that access to
the variable should be as fast as possible. Note that "suggests" is
not the same as "commands," and the compiler may choose to ignore
your suggestion. Nowadays, few compilers pay attention to it, so
you're left with only the first effect.
In the Bad Old Days, `register' could have a significant effect
on the performance of a program. Note that "significan t" is not
necessarily the same as "beneficial ;" sometimes adding `register'
made the program slower ...
-- Er*********@sun .com
James Kuyper <ja*********@ve rizon.netwrites :
RANNA wrote:
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.
<pardon-my-pedantry>
Of course what is meant is that the compiler may ignore the 'register'
storage class specifiers, not that it may ignore the declarations.
</pardon-my-pedantry>
[...]
In article <kf************ *@alumnus.calte ch.edu>,
Tim Rentsch <tx*@alumnus.ca ltech.eduwrote:
>James Kuyper <ja*********@ve rizon.netwrites :
>RANNA wrote:
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.
<pardon-my-pedantry> Of course what is meant is that the compiler may ignore the 'register' storage class specifiers, not that it may ignore the declarations. </pardon-my-pedantry>
<super-pedant-mode>
Someone will come along and point out that the other key thing about
register variables is that you can't take their address.
So, the compiler is not free to ignore the 'register' keyword (as if you
had done: #define register)
in the sense that if you later try to apply the & to such a variable, it
has to flag it.
In article <gf*********@ne ws.xmission.com >,
Kenny McCormack <ga*****@shell. xmission.comwro te:
><super-pedant-mode>
>So, the compiler is not free to ignore the 'register' keyword (as if you had done: #define register) in the sense that if you later try to apply the & to such a variable, it has to flag it.
Ha, call that super-pedantry?
A compiler is free to issue any diagnostics it likes for legal code.
So it could warn every time the address of *any* variable is taken,
and it would then be free to ignore "register".
-- Richard
--
Please remember to mention me / in tapes you leave behind.
Richard Tobin wrote:
Kenny McCormack <ga*****@shell. xmission.comwro te:
><super-pedant-mode>
>So, the compiler is not free to ignore the 'register' keyword (as if you had done: #define register) in the sense that if you later try to apply the & to such a variable, it has to flag it.
Ha, call that super-pedantry?
A compiler is free to issue any diagnostics it likes for legal
code. So it could warn every time the address of *any* variable
is taken, and it would then be free to ignore "register".
No, it isn't free to ignore 'register'. It is free to avoid the
act of assigning a register. It is not free to allow access to the
address of that variable.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
CBFalconer said:
Richard Tobin wrote:
>Kenny McCormack <ga*****@shell. xmission.comwro te:
>><super-pedant-mode>
>>So, the compiler is not free to ignore the 'register' keyword (as if you had done: #define register) in the sense that if you later try to apply the & to such a variable, it has to flag it.
Ha, call that super-pedantry?
A compiler is free to issue any diagnostics it likes for legal code. So it could warn every time the address of *any* variable is taken, and it would then be free to ignore "register".
No, it isn't free to ignore 'register'.
Under the conditions that Richard Tobin stated, it is.
It is free to avoid the act of assigning a register.
Yes.
It is not free to allow access to the address of that variable.
Wrong. If a program attempts to take the address of an object whose
identifier is register-qualified, a constraint has been broken, and this
requires a diagnostic message. If the implementation diagnoses *every*
occurrence of an address being taken, then it will diagnose the taking of
the address of an object whose identifier is register-qualified. It is
then free to produce an executable program, or not - either is legal. The
behaviour of such a program, if produced, would of course be undefined.
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: G Kannan |
last post by:
Hey all!
I have written a perl script to retrieve information from a HTML Form
and insert the data into an Oracle database table. I am gettting the
the following error message:
"Use of uninitialized value in concatenation (.) at register.pl line
38, <STDIN> line 10."
The PERL code is as follows:
|
by: Ioannis Vranos |
last post by:
Just some thought on it, wanting to see any explanations.
It was advised in this newsgroups that we should avoid the use of
keyword register.
However it is a language feature, and if it offers no help to an
implementation, it is free to ignore it. And this happens widely, all my
C++ compilers in my platform ignore this keyword.
|
by: Cheng Mo |
last post by:
I know global varaibles should always be avoided. I asked this question
just for deep insight about C++.
If global variables are distributed among different source code files,
what's the initialziation sequence of these varaibles. Say,
Foo g_fooMain in main.cpp;
Foo g_hello in hello.cpp;
Foo g_bye in bye.cpp;
and main.cpp has code
#include "hello.h"
|
by: Alex |
last post by:
I apoligise in advance if this is an os or platform based question, I
don't know.
I was wondering how register integers (and other types of register
variables) are managed by c++. For example, on a pentium 4, there are
8 register integers in the cpu. If you define more than 8, or if there
are other programs using this space, how are the variables allocated.
This is for a simulation program that needs to be very fast.
For example:
|
by: Shankar Agarwal |
last post by:
I was trying to use a variable whose value is temporary and i don't want
it to go to the memory for performance reasons. Is there a way to specify
the variable like that so that any assignment to the variable does not go
to memory. I tried the type register but it does not seem to work.
Thanks
Shankar
| |
by: aruna |
last post by:
What is the disadvantage of using register
storage class specifier?
|
by: microsoft.public.dotnet.languages.vb |
last post by:
Hi All,
I wanted to know whether this is possible to use multiple variables to
use in the select case statement such as follows:
select case dWarrExpDateMonth, dRetailDateMonth
case "01" : dWarrExpDateMonth="Jan" : dRetailDateMonth="Jan"
case "02" : dWarrExpDateMonth="Feb" : dRetailDateMonth="Feb"
End Select
|
by: Corinne |
last post by:
Hi everyone:
I have created a test.aspx page. (Visual studio 2005)
I want to declare some variables to use in a IF statement to assign other
variables specific values.
I keep on getting some messages telling me "Name 'test' is not declared"
Everything in between the <%%is underlined
|
by: Juha Nieminen |
last post by:
As we know, the keyword "inline" is a bit misleading because its
meaning has changed in practice. In most modern compilers it has
completely lost its meaning of "a hint for the compiler to inline the
function if possible" (because if the compiler has the function
definition available at an instantiation point, it will estimate whether
to inline it or not, and do so if it estimates it would be beneficial,
completely regardless of whether...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |