473,698 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

function without an address?

In days of old, for no discernible reason, many CPU's had the ability
to execute one or more instructions out of registers. Not very common
today.

Which brings up a semi interesting point.

We know the "register" keyword suggests the compiler keep the
following variable in a register.

We also have the "inline" suggestion in C++ to suggest inlining a
function.

What if one could suggest: register int max(a,b) { return a>b?a:b }

.... meaning "you might want to keep this function in registers"

of course the usual "register" and "inline" restrictions would apply--
you cant take the address of this function or pass it as a function
parameter. Plus the registers would be unavailable for any other use.

I guess all these hints are kinda obsolescent as the hardware guys are
always trying to find ways of giving us more speed, like adding a cache
so some variables have register-like speed, same for code cache so some
code executes like it was in registers.

Kinda weird for a function being "there" but not having an address.

Nov 2 '06 #1
7 1417
Ancient_Hacker wrote:
In days of old, for no discernible reason, many CPU's had the ability
to execute one or more instructions out of registers. Not very common
today.

Which brings up a semi interesting point.

We know the "register" keyword suggests the compiler keep the
following variable in a register.

We also have the "inline" suggestion in C++ to suggest inlining a
function.

What if one could suggest: register int max(a,b) { return a>b?a:b }

... meaning "you might want to keep this function in registers"

of course the usual "register" and "inline" restrictions would apply--
you cant take the address of this function or pass it as a function
parameter. Plus the registers would be unavailable for any other use.

I guess all these hints are kinda obsolescent as the hardware guys are
always trying to find ways of giving us more speed, like adding a cache
so some variables have register-like speed, same for code cache so some
code executes like it was in registers.
You never know, these instructions (which CPUs by the way?) may already
be used by some cunning optimiser.
Kinda weird for a function being "there" but not having an address.
Well there are CPUs out there with addressable registers (8051 for
example) so if that set intersects with those with register
instructions, it might be possible :)

--
Ian Collins.
Nov 2 '06 #2
In article <11************ **********@b28g 2000cwb.googleg roups.com>,
Ancient_Hacker <gr**@comcast.n etwrote:
>In days of old, for no discernible reason, many CPU's had the ability
to execute one or more instructions out of registers.
Often this didn't speed things up unless you'd paid extra for
semiconductor registers. (I used to have a PDP-10 price list with the
price for these, but I fear it was destroyed when most of our AI
department burnt down.)

-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 2 '06 #3
2006-11-02 <ei***********@ pc-news.cogsci.ed. ac.uk>,
Richard Tobin wrote:
Often this didn't speed things up unless you'd paid extra for
semiconductor registers. (I used to have a PDP-10 price list with the
price for these, but I fear it was destroyed when most of our AI
department burnt down.)
What were registers otherwise? surely not core memory?
Nov 2 '06 #4
In article <sl************ *******@rlaptop .random.yi.org> ,
Jordan Abel <ra*******@gmai l.comwrote:
>What were registers otherwise? surely not core memory?
Yes.

Looking back at previous threads on this subject, I see that it may be
that DEC never actually shipped any of these machines without the
theoretically optional fast registers:

http://groups.google.com/group/alt.s...8b87a6590ffa44

-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 3 '06 #5
Richard Tobin wrote:
Ancient_Hacker <gr**@comcast.n etwrote:
>In days of old, for no discernible reason, many CPU's had the
ability to execute one or more instructions out of registers.

Often this didn't speed things up unless you'd paid extra for
semiconductor registers. (I used to have a PDP-10 price list
with the price for these, but I fear it was destroyed when most
of our AI department burnt down.)
That was the 'execute' instruction. Some machines could operate on
storage with it. HP3000 for one. It was in a register if on top
of stack.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>
Nov 3 '06 #6
ri*****@cogsci. ed.ac.uk (Richard Tobin) wrote:
In article <11************ **********@b28g 2000cwb.googleg roups.com>,
Ancient_Hacker <gr**@comcast.n etwrote:
In days of old, for no discernible reason, many CPU's had the ability
to execute one or more instructions out of registers.

Often this didn't speed things up unless you'd paid extra for
semiconductor registers. (I used to have a PDP-10 price list with the
price for these, but I fear it was destroyed when most of our AI
department burnt down.)
Evidently Eliza acidentally loaded one of her registers with an HCF
instruction.

Richard
Nov 3 '06 #7
In article <11************ **********@b28g 2000cwb.googleg roups.com>
Ancient_Hacker <gr**@comcast.n etwrote:
>In days of old, for no discernible reason, many CPU's had the ability
to execute one or more instructions out of registers. Not very common
today.
I can only think of two general examples (more on that in a moment).
>Which brings up a semi interesting point.

We know the "register" keyword suggests the compiler keep the
following variable in a register.

We also have the "inline" suggestion in C++ to suggest inlining a
function.
C99 has "inline" as well, with (I believe) somewhat different semantics.
>What if one could suggest: register int max(a,b) { return a>b?a:b }

... meaning "you might want to keep this function in registers"

of course the usual "register" and "inline" restrictions would apply--
you cant take the address of this function ...
In C89, of course, any legitimate use of a function identifier
winds up computing its address.[%] (If a C99 inline function is
actually expanded in line, it makes sense to talk about this as
*not* having "taken the address" of the function, since the code
that implements it has simply been inserted in line, as the keyword
itself suggests. In a sense, the *value* of the call has then been
recorded, instead of the call itself, even if/when that requires
a bunch of expanded-in-line computation.)

On the other hand, if one is writing a Standard, one simply (hah)
goes back and changes the language describing function calls to
make them not "find the pointer" first, at least for inline.

-----
[%] This is not unlike "register T arr[N];" in C89, except that
here, you can do "sizeof arr", making register arrays only *almost*
completely useless. :-)
-----
>Kinda weird for a function being "there" but not having an address.
Back to the two "general examples" ... the first is machines on
which registers have addresses. (PDP-10, TI-9900, possibly others;
I only know of actual "code in registers" instances for the first
though.) In this case, putting code in the registers still leaves
it with an address.

The other example is machines with an "execute indirect" instruction,
where one can, e.g., point a register at a memory location that
contains a single instruction, then use the "exec" instruction to
pull in that single instruction. Sometimes the "exec" instruction
will allow the instruction-to-execute to be in a register itself
(instead of pointed-to *by* a register). In this last case, the
target instruction does not have an address -- but in both cases,
the "function" is only a single instruction. In general, this is
not useful to C compilers, where functions (inline or not) often
need multiple instructions.

In any case, I think if one were designing a C-like language from
scratch, "inline" alone would suffice -- "register inline" is not
so useful after all. Indeed, I think I would rather just define
the language so that functions default to internal-linkage, and
can then easily be inlined during optimization, the same way modern
compilers largely ignore "register" declarations on automatic
variables and just assign registers as appropriate.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 3 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
12099
by: Roy Yao | last post by:
Hello, I need to pass a pointer to a callback function to the lower level modules. But the function is thought to be a virtual member one. How can I get the real address of the virtual member function?
58
10140
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of code... TCHAR myArray; DoStuff(myArray);
11
2706
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
89
6493
by: Sweety | last post by:
hi, Is main function address is 657. its show in all compiler. try it & say why? bye,
4
324
by: Nicole | last post by:
Is there a way to explicitly define the address pointed to by a function pointer without using the address-of operator? Such as: void (*ptrFunction)(void) = NULL; void funcA(void); //Address of this function is 0x0040010A int main(void) { ptrFunction = &funcA; //this works. ptrFunction = 0x0040010A; //this doesn't, and I want it to.
38
2365
by: maadhuu | last post by:
does it make sense to find the size of a function ??? something like sizeof(main) ??? thanking you ranjan.
23
7809
by: bluejack | last post by:
Ahoy... before I go off scouring particular platforms for specialized answers, I thought I would see if there is a portable C answer to this question: I want a function pointer that, when called, can be a genuine no-op. Consider: typedef int(*polymorphic_func)(int param);
8
10501
by: all.junks | last post by:
Hi, Let's say I'm in function foo. I am trying to find the function(or return address) which called foo. Initially, I thought I could use stack base pointer(ebp+4) to find the return address. However, my compiler(vs7) would go through so many function call and ebp+4 points to somewhere in kernel32.
13
3963
by: JD | last post by:
Hi, My associate has written a copy constructor for a class. Now I need to add an operator = to the class. Is there a way to do it without change her code (copy constructor) at all? Your help is much appreciated. JD
0
8601
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,...
0
9021
jinu1996
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...
1
8892
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,...
0
7716
agi2029
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...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4365
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...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.