Jump to content

Talk:Register (keyword)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

@DIYeditor:

@Boeing720: Please read this carefully as I think we have had problems in the past due to an English-Swedish language barrier. I would have broken this out into a bulleted list but I am using numbered in-line points because last time I tried bullets you interleaved your replies with my bullets which makes a mess. You can use these numbers in the same fashion in your reply if you like. 1) This article needs to be for C++ as well to match the article Static (keyword) and because, like static, this is relevant to both languages. Consistency is important. 2) You removed the only citation (of the C99 specification) and information relevant to C itself (not C++) - that you can't access the location of a register variable in any implementation of C, but you can use sizeof 3) that a binary is "nude" is irrelevant to compiler optimization - in other words whether a compiler puts a variable in a register in the optimization phase has nothing to do with whether it is targeted toward a system with an OS or not. 4) I asked for a cite for which compilers (embedded) register is still important. I went ahead and looked into this. For example, for the Microchip MPLAB XC32 compiler[1], in accordance with my information on optimizations, "... variables may be allocated to registers as part of code optimizations. For optimization levels 1 and higher, the values assigned to variables may cached in a register." In the XC32 compiler it is not really along the lines of what you indicated because "The register keyword may be used to indicate your preference for the variable to be allocated a register, but this is just a recommendation and may not be honored. The specific register may be indicated as well, but this is not recommended as your register choice may conflict with the needs of the compiler. Using a specific register in your code may cause the compiler to generate less efficient code." The only way it indicates the register keyword will actually be honored is in terms of your preference for a specific register (which itself is a feature unique to that compiler), which it discourages doing. So I would like to see a citation for documentation of a compiler (embedded) that is contrary to this. —DIYeditor (talk) 07:56, 15 July 2017 (UTC)[reply]

Well first things first. IF there is a language barrier here, (that's IF), then I think it's sooner about C vs C++ than anything else.
Secondly - the C99 standard doesn't work like a new speed limit, it's just one standard among other standards. Further C++ was as of Bjarne Stroustrup back in 1983, c plus a lot more. I did include a reference for the TC.exe compiler. (Which you removed). Mainly the possibility for OOP. All C code was initially considered to also be C++, but not necessarily the other way around. C++ (especially as OOP) a very good language for huge programs. But C has due to its speed remained as the most important language within embedded programming. Whether C still is a part of C++ and similar questions are a matter of discussion, also here. I wrote the register article as a C-keyword (reserved wword) and type modifier, brief but absolutely true. And what static has to do with register, more than volatile or auto, can't I really see. And I have not written about those.
"Proper C" has its main field within embedded programming. By this is meant any device from a new toaster model up to a control system for airliners. It's (usually) developed on desktop PCs etc ,in some cases with help of tools which simulates the hardware for which the software is developed. (The MIPS procsessor is rather widely known for their simulator, but there are others as well) Still much C-embedded programming are made on Microsoft or Borland development software. (But not often, I would argue, on development tools of "visual type" , like Visual Basic, or Delphi. Although there are plenty of such "event-driven" development tools available, not at least from Borland)
Embedded programming can be made by one single programmer - up to a team of perhaps 50 programmers led by a programming engineer. In such cases (with many involved in the development of the software) are the (senior) programming engineer responsible for the final decision of the hardware (although it can be changed during the development). This is not just a technical issue, but what I would like to call "techno-economic". Regardless of the amount of developers, are excessive hardware equally unsatisfying as hardware that's too weak. But for opposite reasons, "the technical - economical balance". Hence are hardware not rarely programmed "tightly" , especially for mass produced and cheap devices.
And when using the C-language is the register type modifier (and keyword) a tool available for such optimization. Mainly for loop-counters, but not only.
Also - programs designed as embedded systems are "nude", direct communication without any ("other") Operative System. (Although huge embedded programs certainly can be more complex than a PC-Operative system is, and can work like an OS as well. (Like on board an Airbus A380, I presume) register isn't "magical" however, and there are many other optimization possibilities (like correct use of pointers) which may help to make the execution of the compiled (and usually linked) code(s) to go faster. This is done at development time, but intended for the final hardware that is going to be used at - and has little to do with the compiler that is used during development. (I just want to be clear about that difference, the XC32 is a compiler and a software (I trust), unlike the processor and other hardware which will execute the final software(s). And since you ask for compilers am I uncertain if you mean the compiler itself ? Or a development environment.) Borland C++ works fine with "register" MSVS from 2001 equally. (if compiling C-code).
"Use the register storage class specifier to store the variable declared in a CPU register (if possible), to optimize access and reduce code. Items declared with the register keyword have a global lifetime" (Borland help) Are you saying the keyword has vanished in brand new development environments ?
For C++ usage, have you yourself said "register" is insignificant. So why bother about that ? For C is "register" still a certain aid, during certain circumstances.(Not more than so, and my initial article was indeed brief) It's not possible to direct a register-declared variable to a certain (hardware) CPU-register. That can only be done by writing "already compiled" code, like machine code, or preferably through the use of the assembly code for the intended hardware in question. (the hardware at where the final software(s) will be executed on. It's possible, but very far from easy). The sizeof keyword will tell you the number of bytes a variable actually occupies (typically whether int/long are different in size - or equal, doubt that's of interest outside the memory (RAM). But show me a brief example how "sizof" might give some help in combination of a register-optimized variable, if you like.
I stand by my first brief & original article, and think if C++ is necessary to involve, could that part just have followed. Chronological order. However I will leave it up to you. (And I will move this discussion to the talk-page of the article, where it belongs) Boeing720 (talk) 23:01, 15 July 2017 (UTC)[reply]
All of static, register, volatile extern and auto should have similarly named and laid out articles if they are to have articles at all. I believe of those only Static (keyword) existed so I based my vision for what the article should be named on that and moved Register (C programming language) to Register (keyword) because it is very important that articles be consistently named. Also, like static, since it applies to more than one language, any related language the keyword applies to should be covered in such an article. I don't think volatile, extern, and auto have individual articles but if they did they should be handled in the same way. Consistency.
C99 was just an example of an actual ISO C standard for which I could find the text online. C11 would be better yet but it is not available for free. C99 is a much more solid citation than "TC.EXE" which is not only just one piece of software, it is ridiculously outdated. However it would not really be any better to use the gcc or Visual Studio documentation as citations versus an ISO standard. What C99 says, I believe, was true going back very far in C and I was using it as a source for statements that apply in general.
I don't know what it has to do with this article how many people work on a piece of code (except that as I want the article to read: if it is declared register, in C you aren't allowed to use it in a way, by accessing the location, that would cause the compiler's optimization not to place it in a register, possibly preventing someone from accidentally misusing a variable intended to be in a register), or why this article should be primarily related to embedded systems. Clearly embedded systems are relevant but so is, say, the Linux kernel. Also, C is not dependent on the implementation or target. It is worth discussing implementations but the standard doesn't depend on them.
Of course register is available. My point is that it does not do much anymore because optimization will put variables in registers anyway if possible, automatically. The main difference is that in C (but not C++) it imposes the limitation that you cannot access the location (say, with the & operator) of variable declared with register. That is the only significant difference you get by using register in all (that I know of) modern compilers if optimization is enabled.
Only the compiler determines whether a variable is stored in the register. Neither the operating system (or lack of it) or the hardware make that determination. Obviously a compiler is targeted to a specific CPU and linking is targeted to a specific OS but it is the compiler that decides where to put a variable and how to use it. That's why I asked for which compiler you are thinking of where optimization doesn't automatically put variables in registers if beneficial. I gave the example of the Microchip™ XC32 compiler because that is for a very common embedded architecture and you seem focused on embedded. I am trying to work with you. By the way, "nude" is not a term used as you described. It doesn't make sense to make up terminology for technical articles.
I'm not saying the keyword has vanished in new environments, I'm saying optimization in every modern compiler automatically puts variables in registers if appropriate.
C++ is relevant because the register keyword still exists there. It is possible with the XC32 compiler, per the cited documentation, to direct a variable to a specific register which is why I included that. That may be a quirk unique to that compiler because I also have not heard of that before. I mostly included that you can use sizeof because the C99 standard indicated that was significant, but I think it is clear why you might want to know what size a register variable is. It's silly to ask for an example of how that might be used.
The issue of C vs. C++ was treated separately in my version of the article. The only place I really mentioned C++ was saying "but not in C++ where it is essentially ignored". There wasn't much about C++ to merit a separate section since the information about it could be included in the same sentence. This is different from the Static (keyword) article where static has more extensive additional meanings. We could break the discussion about C++ into a separate section though, if you feel my version is confusing. —DIYeditor (talk) 12:54, 18 July 2017 (UTC)[reply]

Nobody's perfect

[edit]

@DIYeditor:

I believe your complaints about my English was related to the list of C-keywords, and the brief describing of them, in a one line column. So the brief explanation had a quite limited space. Hence, did I use abbreviations and cut corners in several other ways. Which, just by the way, also was done in the "original" Swedish text. That might possibly be somewhat of a "linguistic culture clash" ?? I just don't know. But I do know that abbreviations are quite popular in written Swedish, also in an encyclopedic perspective. For instance, Swedish encyclopedias typically only uses the first letter in articles, after its first mentioning. Here follows an example taken from the 1950's "Svensk Uppslagsbok" - article is "Venezuela" (as it's the first one in the 31:st volume, which I just happened to have at hand) and just a few lines from its lead. And I skip the phonetics, as I think I suffered from some kind of disease that day, when phonetics was taught :)
.
In Swedish -
"Venezuela [phonetics] off. Republica de V. , förbundsstat i n. Sydamerika... ...V. gränsar i v. och s.v. till Colombia, i s. till Brasilien och i ö. till Brittiska Guayana (se karta vid Bolivia); till V. höra även [some islands]...."
.
In English with the same abbreviations -
"Venezuela [phonetics] off. Republica de V. , a federal state in n. South America... ... V. borders in the w. and s.w. to Colombia, in s. to Brazil and in e. to British Guayana (see map by Bolivia); to V. does also [some islands] belong"
.
In English without abbreviations -
"Venezuela [phonetics] officially Republica de Venezuela , a federal state in northern South America... ... Venezuela borders in the west and south-west to Colombia, in the south to Brazil and in east to British Guayana (see map by Bolivia); to Venezuela does also [some islands] belong"
.
I've got no access to any English (printed) encyclopedia. So I don't know to what extent abbreviations are used in English encyclopedic language. I do however know that we don't need to shorten words as in the example. But regarding that list, I didn't give that much thoughts - not more that to give as much help to the readers as possible. That was perhaps a wrong to do. But with exception of some mocking on my written English at talk-pages and I especially recall when "manner" became "manor" in a sentence, which apparently gave some other contributors an opportunity to make a joke. Which also I found to be really funny, as the "coin dropped down". My self rate has always been 3. I could say, five years ago, that value possibly could have been 2.8 but as one actually improves could it today be 3.2 possibly. That's if we had a decimal self-rate possibility. I am indeed aware of not being native in English, as well as translation in general goes from the foreign language to the native one. But I began to learn English (British English) in third grade.And I have studied the English language for 7 years in primary school and during 3 years in secondary school. (And at university-level have I read litterature in English) Add to that all English/Scottish/Irish and American and Australian television and film, which always been a certain natural help. Just as some 15 visits to England also have been of linguistic benefit. English is also from a linguistic aspect not that far from the Scandinavian languages, and has a simpler grammar compared to the German one. Not even when I was brought to "court" (AN/I) did any of the two "prosecutors" complain about my English. So I don't think you have to worry too much about my English. But I will never become a new Shakespeare. That is however similar to my native language, which I prefer to call Scanian (Swedish with quite a lot of Danish elements, vocabulary as well as pronunciation. Especially the use of guttural-R). Cheers ! Boeing720 (talk) 12:07, 17 July 2017 (UTC)[reply]
@Boeing720: No, it was not just your descriptions of the keywords but rather your whole sentences which contain a few persistent grammatical quirks. I think we may be in the wrong place to discuss this (your talk page would be more appropriate) but I will take the time to give you examples from here and C programming language. Please don't interleave your responses, if any, with my individual points and please do give your responses, if any, below my entire post.
  • "It suggest the compiler to store a declared variable in a CPU register, instead of in the memory."
4 errors, should be:
  • "It suggests that the compiler store a declared variable in a CPU register, instead of in memory."
  • "Later has more keywords been added, but most of them are intended to widen the C-language into new areas outside Embedded system."
6 errors, including a common one for you where you put the verb before the direct object in cases like "Later has more keywords been added" instead of "Later more keywords have been [were] added":
  • "Later more keywords were added, but most of them are [were] intended to widen C into new areas outside embedded systems."
  • "Normally does a C-programmer also require a number of functions."
Another verb order problem, this time putting the verb before the subject or splitting "does require", using "does require" instead of "requires", and hyphenating things that should not be:
  • "Normally a C programmer also requires a number of functions."
  • "If the amount of keywords are few, does C instead offer a lots of prepared functions."
Verb problems, amount vs. number, are vs. is, this "does C instead offer" problem again, "a lots" instead of "a lot" which should be "many":
  • "While the number of keywords is few, C instead offers many prepared functions." or better "While there are few keywords, C offers instead many prepared [ready-made] functions."
These errors may seem small but they indicate a much less than "advanced" level of English (more like en-2 than en-3) and seemed to mirror some problems I felt I had in communicating my reasons for adjusting your edits. I appreciate that you are working in a foreign language and mistakes may be made but some of these mistakes seem persistent throughout your work on Wikipedia and leave something of a mess for others to clean up. They are ungrammatical enough to cause some readers significant confusion. But again, my concern was not as much with your grammar mistakes in articles but in there seeming to be a language barrier when trying to communicate with you via edit summaries and in talk pages, although part of that may be related to what I perceive to be knowledge gaps on your part in the technical nature of the topics. It's not a big deal just a bit frustrating. I'm far from a grammar expert myself, just a native English speaker. Certainly nobody is perfect and mistakes happen; hopefully we can learn from them. Thank you for taking the time to explain your background and perspective. —DIYeditor (talk) 13:33, 17 July 2017 (UTC)[reply]
A few comments. You kept all the examples to the same part. It's is technical, and I may have prioritized that aspect rather than grammar. As I wrote that part (essentially all related to the C-language, except the original of this article, which was free of actual errors as well as of grammatical ones) You never even bothered to explain why you felt static has some kind of "special" relation to register. My guess is what you really wanted to be "the opposite of" static is extern.
But in retrospect I admit, to have written that part a bit hasty, possibly stressed by you. I should at least have read it a second time. If I had read it a second time, which I normally do, then at least the worst two errors you have found there, would have been corrected. Time stamp is 6:54 (8.52 CEST) and I was going to sleep (not "just woken"). Is this the language barrier, you refer to ? Explaining the circumstances - or were there any question to which I didn't reply ?
About your actual criticism of that single contribution. "a lots" is indeed awful - indecisive article followed by plural. And naturally the same about "the number of keywords is" - Shame on me ! However you also appear to do serious grammatical mistakes yourself!
you wrote (above):
"Verb problems, amount vs. number, is vs. are" (the latter fault have I just replied to)
This concerns me "bigly" (the new adverb the new President attempted to coin, or at least used. And which Jimmy Fallon repeated without any further comment...) Given your depth analysis of a fraction of my contributions, including the conclusions you then base on this analysis, do I find it rather strange that you make a so serious grammatical error, which clearly indicates that you even can't differ between nouns and verbs entirely! The words "amount" as well as "number" are both nouns, not verbs. Do you think I should begin to examine your grammar ? And are you not aware that there are English speaking foreign nations besides your own, which ever that may be ?
No ! I'm just attempting to show you, how you come up with your conclusions and verdicts.
And this isn't funny to read
  • "some of these mistakes seem persistent throughout your work on Wikipedia and leave something of a mess for others to clean up." - But then later "It's not a big deal just..." and "Certainly nobody is perfect and mistakes happen; hopefully we can learn from them." I can agree to the two last ones. And that morning which you keep referring to, isn't representative for my contributions, from a grammatical perspective. And I'm an at university level examined programmer of embedded system. And I have sudied C, C++ for OOP, assembly of MIPS, HC11 and some other chip with a smaller instruction set. I have also worked with embedded programming professionally, within the Assa-Abloy concern at a software/hardware developing company called Timelox during 4½ year. (I had never use for C++ there) And right now am I feeling real tired. I can't go through a grammar check right now. Boeing720 (talk) 03:38, 18 July 2017 (UTC)[reply]
Your grammatical problems are at this point probably a bigger issue than the technical, but it is hard to tell. I was only trying to be polite and cooperative when I said it's not that big of a deal. You don't seem to want to acknowledge how many clear errors were contained in the above examples or learn from my corrections (like how you still say "embedded system" instead of "embedded systems" when you mean plural). The "grammatical mistakes" of mine that you try to highlight seem to amount to one item in a list of things that weren't intended to be directly connected - and I wasn't trying to make an addition to an encyclopedia article with that, but rather to save space. I know quite well that "number" and "amount" are nouns; I meant with that list that there were verb problems, and you were confusing "number" with "amount", and "are" with "is", etc. I was giving a list of the (numerous) problems in your sentence, not trying to write a complete sentence. Perhaps I should have gone into more extensive descriptions of the problems with each example in plain English in complete sentences to avoid any confusion, because it is plain that confusion is likely in this exchange. Trying to turn this around on me is a ridiculous way to try to avoid how bad those examples of your text were; I could be terrible at English but that would not make yours any better. It would be obvious to any native English speaker, or advanced level English speaker, that there were clear and significant errors in the sample text I gave. I assure you that in any country where English is spoken those example sentences I gave would be described by everyone as "broken English". I'll accept that maybe this is not indicative of your best English as you do seem to be able to express yourself somewhat more clearly outside the article, which doesn't make sense because in the articles is where it counts. By the way, it would be beneficial to pay closer attention to international news stories if you are going to cite them; Trump didn't make up a new word "bigly", he said "big league" which is itself pretty crappy English but that's another matter entirely. Truth be told, your English was so bad in these two articles that it was quite difficult to tell whether you were having more of a problem with the technical nature of the articles or with English. As to your technical points I will try to respond to your comments above in that section, although to be honest I have trouble understanding your English well enough to do so and it will require some thinking and guessing. —DIYeditor (talk) 12:11, 18 July 2017 (UTC)[reply]
Quote "I'll accept that maybe this is not indicative of your best English" - thanks ! "Amount" is related to quantity - of largely anything and "number" is a synonym. "A number of occasions" usually means "(rather) many times". etc. And I know well, that you know quite well, that "number" and "amount" are nouns. But still you made a mistake. Like I did in the C-article. (OK I made more mistakes than you, did, but still) I had a bad day, obviously.
I have never ever before been accused of bad grammar before. Not even during my only experience of AN/I. (sorry for the external link)[[2]] If there had been any language problem as well, then I'm pretty certain they would have played that card as well. But neither of them did. And one of the two seems to be extremely hard on "bad English" (in an other AN/I case, which very well may be in the same archive). Boeing720 (talk) 02:31, 19 July 2017 (UTC)[reply]

Example disproves

[edit]
Wikipedia is not a forum to chat about topics, WP:NOTFORUM. Johnuniq (talk) 21:22, 13 February 2018 (UTC)[reply]
The following discussion has been closed. Please do not modify it.

@DIYeditor:- this is bullocks "Aside from this limitation, register is essentially meaningless in modern compilers due to optimization which will place variables in a register if appropriate regardless of whether the hint is given." and the example proves it! Boeing720 (talk) 02:49, 10 February 2018 (UTC)[reply]

# gcc -O1 registertest.c
# ./a.out
Memory store: 3 ticks

Register store: 3 ticks
  1. Your code does not even compile there are obvious errors like printf= and missing semicolons.
  2. Your loops are obliterated by optimization so it is impossible to tell what effect optimization register has.
  3. PAUSE is not a standard system command.
  4. What is "int a,aa,b,bb,c,cc,d,dd,e,ee,f,ff,g,gg,h,hh,i,ii,j,jj;" for?
  5. Ugly formatting.
  6. Original research.
  7. Fact that this is obliterated by optimization and such an absurd "test" further illustrates questionable competence at this as have previous edits.
Please stop this silliness. It's hard to be polite about it. —DIYeditor (talk) 03:17, 10 February 2018 (UTC)[reply]
  1. the Wikipedia "code" caused me huge problems.
  2. i an j are not supposed to be stored in the CPU, whilst k and l are - for this tiny comparacy.
  3. When many variables comes in to play, the compiler very often do wrong choices as the number of CPU registers are limited.
  4. system() is standard intended to for executing OS commands. system("PAUSE") on Windows pauses the command window to vanish. It can be replaced with Scanf or whatever that does not close the window.
  5. The compiler can override global variables (and optimize to CPU register), but if many - this becomes less likely.
  6. - the Wikipedia code doesn't work properly. Was it something else you referred to ?
  7. No research - evidence.
  8. the idea is to illustrate what the difference becomes, with a TINY program. Increase the values of MAX and LAPS to 150.000 each - if you have a special math processor , the difference will not show. On an ordinary PC, a "gaming PC" with mothercard ASRock 990Extreme3 I got 294 vs 978. At this (older one) 1187 vs 438.
Entire code "as is"

  1. include <stdio.h>
  2. include <time.h> /* for clock_t declaration and clock() function */
  3. define LAPS 200 /* illustrate other usage of define preprocessor directives */
  4. define MAX 200

/* don't go over the limit for your int - that's hardware dependable*/

int a,aa,b,bb,c,cc,dd,e,ee,f,ff,g,gg,h,hh,i,ii,j,jj; /* only i and j will be used - the others for simulation of a larger program*/ int main (void) {

 register int k;
 register int l;
 long tmp;
 clock_t start; /* defined as clock_t variable defined in time.h */
 clock_t finish;
 for (a=1;a<LAPS;a++) {for (aa=0;aa<MAX;aa++);{tmp+=aa/a;}}
 for (b=1;b<LAPS;b++) {for (bb=0;bb<MAX;bb++);{tmp+=bb/b;}}
 for (a=1;c<LAPS;c++) {for (cc=0;cc<MAX;cc++);{tmp+=cc/c;}}
 for (d=1;d<LAPS;d++) {for (dd=0;dd<MAX;dd++);{tmp+=dd/d;}}
 for (e=1;e<LAPS;e++) {for (ee=0;ee<MAX;ee++);{tmp+=ee/e;}}
 for (f=1;f<LAPS;f++) {for (ff=0;ff<MAX;ff++);{tmp+=ff/f;}}
 for (g=1;g<LAPS;g++) {for (gg=0;gg<MAX;gg++);{tmp+=gg/g;}}
 for (h=1;h<LAPS;h++) {for (hh=0;hh<MAX;hh++);{tmp+=hh/h;}}  
 
 start=clock();
 for (i=1;i<LAPS;i++) {for (j=0;j<MAX*1000;j++);{tmp+=j/i;}}
 finish=clock();
 printf("Memory store: %ld ticks", finish-start);
 start=clock();
 for (k=1;k<LAPS;k++) {for (l=0;l<MAX*1000;l++);{tmp+=l/k;};}
 finish=clock();
 printf("Register store: %ld ticks", finish-start);

 getchar();
 return 0;

}

From editing mode this looks fine. I've replaced system with getchar so stdlib.h is no longer requiered. I guess you can use lager numbers - if you just got 3 ticks. It's just to change them as you like in the declare directives. I didn't bother with parameters to the program. Do you wish me to do so ? Boeing720 (talk) 03:56, 10 February 2018 (UTC)[reply]

You really need to stop. You didn't seem to read anything I said. Declaring variables that are never used has no effect. The reason it's only 3 ticks is because of optimization. No higher number of loops would make any difference. Offering "evidence" is original research. This further proves that to be honest you have no business editing this sort of article. There is no way to be polite about it and it is getting quite old. Right on the heels of your nonsense NOTE in the Adobe Flash Player article... —DIYeditor (talk) 04:02, 10 February 2018 (UTC)[reply]
They do as global. What complier do you use ? Boeing720 (talk) 04:07, 10 February 2018 (UTC)[reply]
GCC, one of the most common. It really doesn't matter much what compiler, operating system, or "special math processor" you try this on, if you turn on optimization that kind of loop that does nothing is going to be reduced to nothing. You should really install Linux if you don't want to upgrade from Windows XP or whatever, so you can get some current software. Also Microsoft Visual Studio Community 2017 is available for free but I guess that would require current Windows. It doesn't matter much, I imagine if you turned on full optimization in Borland Turbo C or whatever it is you are using, the difference would vaporize. Even without optimization on the difference with gcc is negligible. But unoptimized code is not horribly relevant, is it? Do you understand what compiler optimization is? To be absolutely as polite as possible, I really feel that you do not have even a rudimentary understanding of computers, C or compilers adequate to edit these sort of articles in the fashion you have been attempting. —DIYeditor (talk) 04:26, 10 February 2018 (UTC)[reply]
BCC the most common one, try now! Boeing720 (talk) 04:32, 10 February 2018 (UTC)[reply]
To answer your question, compilers are getting smarter and smarter, yes. Already Visual Basic ignored empty loops. It may be THAT - but if there is workload in the loops, your argument won't hold. This is about the difference between CPU storage and memory storage. Even the best compiler at the fastest computer can't optimize more CPU registers than exists. And far from. Please don't make assumptions on my knowledge. If neither this works, then the loops are recogniced as empty (as with Visual Basic 5 or 6). But that's not the issue. If empty loops are recognized then also this version will fail, but not if something is done inside the loops. Then the compiler will use CPU registers and memory. But try this first. Boeing720 (talk) 04:45, 10 February 2018 (UTC)[reply]
(edit conflict) You are wrong. Deciding whether or not to put a variable in a register, just like eliminating empty loops, is part of compiler optimization. Also please read register allocation. As to your knowledge, I don't have to assume anything. It is clear from everything you say. Please see Dunning–Kruger effect. And I think you are forcing me not to be entirely civil. Please read all three of those links before responding. At least the first two, Dunning-Kruger is just a bonus. —DIYeditor (talk) 05:01, 10 February 2018 (UTC)[reply]

Now I have added workload in all loops, and EMPTY LOOPS cannot be disregarded from, I also reduced the loop counters. Note this I havn't compiled. Just added here. Boeing720 (talk) 04:58, 10 February 2018 (UTC)[reply]

Please just cease this entire line of thinking/behavior/editing or I will be forced to add it to your list of issues to be taken to ANI. Which at most unfortunately would just result in a warning, but I will add it to the list. —DIYeditor (talk) 05:01, 10 February 2018 (UTC)[reply]
So it did work with workload ! And everything you suddenly thought of my lack of knowledge just come down to GCC jumps empty loops, which really isn't about advanced compiler optimasion at all. On Linux - I have used Slackware om occasions during a few years in the past. Parallel with Windows 98SE or whatever it was. But lacked good literature on Linux in general. Boeing720 (talk) 05:46, 10 February 2018 (UTC)[reply]
No, it didn't make any difference (well, 1 tick each now). I gave you one last chance to drop this. —DIYeditor (talk) 05:57, 10 February 2018 (UTC)[reply]

Ok, just for fun, I fixed some of your errors (extraneous semicolons, divide by zero, uninitialized variable, no newlines). The test is still poorly designed and I didn't try to fix that.

Without optimization (gcc -O0):

Memory store: 1588397 ticks Register store: 1274641 ticks
Memory store: 1489207 ticks Register store: 1272370 ticks
Memory store: 1574000 ticks Register store: 1323891 ticks
Memory store: 1507071 ticks Register store: 1269799 ticks

With optimization (gcc -O1):

Memory store: 138140 ticks Register store: 135433 ticks
Memory store: 126543 ticks Register store: 140898 ticks
Memory store: 133753 ticks Register store: 145676 ticks
Memory store: 131794 ticks Register store: 125634 ticks

But the point here is not to debug your shoddy code examples or for us to do original research on what compilers do what. The point is that this rubbish has no place in an encyclopedia article. —DIYeditor (talk) 08:09, 10 February 2018 (UTC)[reply]

forgot about the workload loops and division, just to begin from 1. This is no OR - similar examples can be found in most works on C-language, Herbert Schildt satates "about 50%". It's often so that size is of importance, within embedded program especially. Release versions may not optimize like this, and so on. "Can't have a larger EPROM" etc. By the way the compiled executive programs should give same readouts. Don't know if you compiled four times - or run the program four times. Made minor adjustments, the "workload loops" does not need to run as long as the ones that are "clocked". Boeing720 (talk) 09:21, 10 February 2018 (UTC)[reply]
No OR! - Herbert Schidt, "C" or "Teach Yoursef C" ,3rd edition (in English), ISBN 0-07-882331-0, p.344 - a similar enough example. Optimal compiling optimization would be to reach the same executable code as if written in machine language. There may be reasons for empty loops, and if the compiler "optimize" a such away, it is to ignore the programmer's code rather than optimization. Boeing720 (talk) 19:14, 11 February 2018 (UTC)[reply]
Sorry, "register" is only a hint it is not mandatory, there is no keyword for RAM storage of a variable, and nothing says the compiler can't put something in a register that's declared as int. Apparently your books are as weak/outdated as Turbo C is. gcc is the gold standard for C compilers. Please just stop. —DIYeditor (talk) 02:00, 12 February 2018 (UTC)[reply]
First there is something very strange with your results in general. You have far too many ticks. Anyway, the code should be compiled as release (and overlay - for windows). "Flash" or compile at the line (with correct parameters), but always ignore the first result, at least if flashing. And then run the already compiled executable file. With as little multitasking as possible. Have you optimized for speed or for size, by the way ? How large did your compiled executive program become ?
I only referred to Schildt as you made the complaint it was OR. Now you use that against me in a very unfair manner, I must say.
Borland's BCC32 compiler and Development environment are professional tools. Are you questioning that ? The register keyword should only be used for a very limited number of variables, due to the limited number of CPU-registers. The "register" keyword (which comes from CPU-register store; initially intended for "int"s only, but that was a long time ago) is a suggestion to store a variable in a far faster CPU-register instead of in the slower memory. But we have the static flip-flop L1,L2,L3 caches in between... - but that's equal to both of us, I suppose. To my knowledge the OS decides how to use the caches. Doubt any standard C/C++ can, I gather one must go to assembler with the exact code table for everything processed or stored temporarily, but that's a guess only.
Anyways. If one declares too many register variables, THEN the compiler has to store some of them in memory instead (which I never have suggested can't happen - and hence one must choose register variables with some care. Two or possibly three per function, otherwise the most "precious" one might end up in memory), but if so then one can get it's address! If a "register variable" indeed is stored in a register, you can't get any address with the &-operator (as there is no memory address). Hence it's possible determinate where the variables actually are stored. But this calls for pointers and a rather unusual error handling, I suppose - I've never had a reason to do a such examination before. But it can be done. Would you like me to do it ?
Do you suggest any compiler ever can beat machine code properly written, in size or in speed ? Or through the assembly language for the hardware in question, but TASM32 for 32-bit OS, usually works. Why did you mention Turbo-C ? I downloaded tdm-gcc-5.1.0-3.exe but as it demanded to connect already before expansion (at a far better unconnected desktop than this one) I didn't bother. I shall try Pelles-C instead, that's supposed to be just as good as any unprofessional C/C++ tool for Windows, some say at least. I really can't install any Linux right now. But I can agree with you that it would have been preferable if Linux had became "standard", and a long time ago. It's safer in general and supposedly easier to comprehend at deeper levels. (Strongly doubt anyone can explain what all files in the Windows-directories do) I tried "Red Hat" briefly, then "Slackware" for more than a year (together with Windows though). If I only had had better literature on the subject then, it might have been different now. Is there, to your knowledge, any possible way to run "Microsoft Flight Simulator 2004" on Linux, by the way ? Boeing720 (talk) 22:48, 12 February 2018 (UTC)[reply]
Also [3] (although it gives you right from some aspects) Boeing720 (talk) 23:09, 12 February 2018 (UTC)[reply]
This is tedious:
  1. Presumably I got more ticks because the timer is higher resolution. I assume BCC has a non-standard "clock()" because I know gcc/libc on a Mac is standard - it's a certified Unix system. You know that Unix is where C comes from right? It's the standard. There is not a "release" flag for GCC at the command line. I used appropriate optimization for release code.
  2. Borland C/C++ is not "professional" considering it has not been updated for some time (20 years?) and has always been a bit flakey. Visual Studio is standard for Windows. The community edition of VS is also free. Borland might have been considered professional in the early 90s although I believe it was considered second rate even at that time.
  3. The difference between -O0 and -O1 did reflect putting the variables in registers even when register wasn't specified. One can deduce to a reasonable degree, from the limited number of variables at play, knowing how the compiler's optimization works, and how many registers the CPU has, which variables are being put in registers.
  4. I strongly suggest learning C++ if you want to do exception handling.
  5. No I don't want you to do any more OR example code or try to insert any more example code in talk pages or articles.
  6. I mention "Turbo C" because you did in your original edit to this article, a reference to the documentation of a discontinued hobbyist compiler.
  7. I didn't say Linux was "standard" although it is widely used on professional servers (and smartphones, etc.). Your example code and additions to articles would be more relevant (that is to say relevant at all) if you were using Linux and they were written to reflect that. One could as easily use Microsoft Visual Studio Community or gcc for Windows.
  8. This is not a forum, why don't you ask Google if and how you can run MS Flight Sim on Linux (or what the best way to install gcc and libraries under Windows is).
  9. Wordpress is not a citation for this article. Neither are outdated learn-to-program books, especially when interpreted in a questionable way as you seem prone to.
—DIYeditor (talk) 07:36, 13 February 2018 (UTC)[reply]
Above it all. What I suspect, is that GCC don't use CPU-registers (due to register keyword, naturally) but the caches, which to my knowledge are based on "re-connected gates" (flip-flop may be a Swedish term, but doubt that). Imagine a pair of NOR gates wwith a total of four inputs and two outputs (one each), but one input each comes from the output of the other NOR gate output (both output lines continues) , see SR latch, for NOR gates (the American illustration is very good). A such can keep a binary value without any refreshing just as long as there is electrical tension (and hence there's no need syncronization either). Faster but far more expensive compared to all conductor versions of memory. I don't know the difference between L1,L2 and L3 caches though, and this isn't really my field. But they are faster than any dynamic RAM, syncronized or not, and so are the PC caches.
The last codes I provided here (the very tiny one and the one with many pointers) - code clearly demonstrated that bcc32 sometimes optimizes the CPU-registers away although declared with "register", but not when it matters. Don't you think it would be nice to know the limits of gcc from the same aspect ?
Reply on C++ (which was a sudden jump) - I can , and have worked with Object Oriented Programming. But if not using OOP, I think C is better. (Well even QB 4.5 can be of good use for simpler to medium tasks, but doesn't function on 64-bits system OS.) OOP are best for huge programs (measured in number of code lines, I've read "at around 1000+ lines structured program begins to be difficult to oversee" or something in line with that, but that was in a C++ book (I think) and I don't know if the statement referred to the whole code or to the longest file). But for embedded programming like hotel doors system or a lift system, C++ isn't suitable, not in my experience at least. Embedded programming is rather a combination of C and assemler for the hardware, standard headers can rarely be of help. Bu never invent the wheel twice, at a software developing office, there usually are thousands of asm-functions in hundereds of #include "headername.h" headers. The world is full of such (mainly c & asm) programs, inside everuthing from toasters, shavers, microwave and other kitchen equipment, various instruments, street lights system, hospital equipment, aviation equipment etc - from the tiniest to the hugest of machines. But for like a bank account system I can well imagine OOP is very suitable, and C++ is the best OOP-allowing language I believe.
And we did both came out of regular Wikipedia scope together, I think. Boeing720 (talk) 16:55, 13 February 2018 (UTC)[reply]
Forgot, Turbo-C was a kind of education tool. No executable files were created at compilation. But warnings and errors were shown. It had (still has) however a very good indexation for help. A-Z wise. That index includes keywords, functions, headerfiles, build in constants, the whole lot - for C and C++. What's ANSI, C99 and C++ is easy to determine. Simple examples. Etc. You shouldn't pick on everything you haven't discovered/learned about so far in your life. This was meant as an advice. Boeing720 (talk) 17:13, 13 February 2018 (UTC)[reply]

Register in other languages?

[edit]

Any other instances of it, apart from C/C++? Andy Dingley (talk) 15:00, 8 November 2019 (UTC)[reply]