473,395 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

indirect jmp

Hi,

What C statement(s) would translate to indirect jmp in assembly? I know
that function pointer invocation would translate to indirect 'call'
instruction, but I am not sure what will lead to indirect jmp (eg. jmp
<register>).

Ganesh

Nov 15 '05 #1
13 6887
In article <11**********************@g14g2000cwa.googlegroups .com>,
<ga*****@gmail.com> wrote:
What C statement(s) would translate to indirect jmp in assembly? I know
that function pointer invocation would translate to indirect 'call'
instruction, but I am not sure what will lead to indirect jmp (eg. jmp
<register>).


longjump() would be the closest. Not that it's particularily close,
but it's all that there is.

In particular, you cannot take the address of a label or of
a statement block or of any executable element other than a routine,
and (as you note) there is no goto a routine.

Depending on what you are trying to do, you might want to look
into techniques that people have developed for emulating
"co-routines".
--
Watch for our new, improved .signatures -- Wittier! Profounder! and
with less than 2 grams of Trite!
Nov 15 '05 #2
ga*****@gmail.com writes:
What C statement(s) would translate to indirect jmp in assembly? I know
that function pointer invocation would translate to indirect 'call'
instruction, but I am not sure what will lead to indirect jmp (eg. jmp
<register>).


There is no direct equivalent. A switch statement comes close.

What are you trying to do? An indirect jump is a technique, not a
problem; what problem are you trying to solve?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #3
ga*****@gmail.com wrote:
# Hi,
#
# What C statement(s) would translate to indirect jmp in assembly? I know
# that function pointer invocation would translate to indirect 'call'
# instruction, but I am not sure what will lead to indirect jmp (eg. jmp
# <register>).

No direct equivalent in ANSI C. gcc has label variables.
--
SM Ryan http://www.rawbw.com/~wyrmwif/
So basically, you just trace.
Nov 15 '05 #4
I am not trying to solve any problem. I am just wondering why indirect
jmp is kept in an instruction set.

Nov 15 '05 #5
ga*****@gmail.com wrote:
I am not trying to solve any problem. I am just wondering why indirect
jmp is kept in an instruction set.


This group is nothing to do with the whats and whys of processor
instruction sets, only to do with the C language. So, as far as I can
see, any such wondering is not relevant here.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #6
I will re-state my problem. Name a C statement(s) that would certainly
make any compiler to generate indirect jmp instruction? (BTW, I am yet
to look into the co-routine suggestion given by one of the posters).

Ganesh

Nov 15 '05 #7
In article <11**********************@g14g2000cwa.googlegroups .com>,
<ga*****@gmail.com> wrote:
I will re-state my problem. Name a C statement(s) that would certainly
make any compiler to generate indirect jmp instruction?
There is no such statement. C may be implimented on machines whose
processor lacks indirect branches.

On some architectures, with some compilers, with some code patterns,
C compilers have been known to generate indirect branches for some switch
statements.
(BTW, I am yet
to look into the co-routine suggestion given by one of the posters).


That was me, and my suggestion to look at co-routines was in
the opposite direction completely: it was a suggestion to look
at a particular field of programming in which people have worked
on techniques to get around the *lack* of an indirect branch.
That is, if you had a particular problem in which you were thinking,
"Gee, I'm not sure how to solve this without using an indirect
branch", then you could look at successful co-routine implementations
to see how they got around the lack of an indirect branch.
--
University of Calgary researcher Christopher Auld has found that
milk is the most "rational addiction" amongst the several studied.
Nov 15 '05 #8
ga*****@gmail.com wrote:
I will re-state my problem. Name a C statement(s) that would certainly
make any compiler to generate indirect jmp instruction?
None. For a start, there is nothing to say C cannot be implemented on a
processor which does not support indirect jumps. The same answer applies
to any other instruction.

We do not deal with system specifics here.
(BTW, I am yet
to look into the co-routine suggestion given by one of the posters).


They are also off topic here since they are not part of standard C.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #9
ga*****@gmail.com wrote:

I am not trying to solve any problem. I am just wondering why indirect
jmp is kept in an instruction set.


Umm... Because they're useful?

Even if no C compiler in the world ever used an indirect jump, they would
still be useful to people who program in something other than C.

If you're looking for a C construct which _might_ generate an indirect
jump on a system which has such an instruction, look at switch/case.

And finally, read some of the multitude of posts on this list which show
how to properly use Google's broken interface to reply.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Nov 15 '05 #10
In article <43***************@spamcop.net>,
Kenneth Brody <ke******@spamcop.net> wrote:
If you're looking for a C construct which _might_ generate an indirect
jump on a system which has such an instruction, look at switch/case.


Also, consider that C *does* have something corresponding to an
indirect subroutine call.

-- Richard
Nov 15 '05 #11
ri*****@cogsci.ed.ac.uk (Richard Tobin) writes:
In article <43***************@spamcop.net>,
Kenneth Brody <ke******@spamcop.net> wrote:
If you're looking for a C construct which _might_ generate an indirect
jump on a system which has such an instruction, look at switch/case.


Also, consider that C *does* have something corresponding to an
indirect subroutine call.


Which the OP mentioned in his original article.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #12
ga*****@gmail.com wrote:
Hi,

What C statement(s) would translate to indirect jmp in assembly? I know
that function pointer invocation would translate to indirect 'call'
instruction, but I am not sure what will lead to indirect jmp (eg. jmp
<register>).

Ganesh

Here is an example where an indirect call is produced, although there is
no requirement or justified expectation that anything in C translate to
anything in assembly.

We have a program to calculate the thermodynamic properties of 45
substances. One routine, which calculates enthalpy (h) from internal
energy (u), pressure (p) and specific volume (v), performs a
substance-independent calculation, but has to call one of the 45
substance-specific routines to compute some terms in the calculation.

Rather than using a long chain of "if" .. "else if" ... or "switch"
statements, we store pointers to the functions in an array, and call the
proper member of the array, the selection being made at run time based
on the value of the integer "subst".

On an X86 machine, gcc compiles the call to the indirect call instruction

call *_pvtptr-4(,%eax,4)

If you are willing to admit a "call" instruction as equivalent to a jump
with some additional bookkeeping for the return link and stack
adjustment, this is one example.

N. Shamsundar
University of Houston
________________________________________
typedef void (*pvtpointer)(double, double *,double, double *,double *);
pvtpointer pvtptr[]={
pvtnh3,pvtco2,pvtc7h16,pvtc6h14,pvc5h12i,
<-- dozens more such function names cut out -->
pvtisb87,pvtbut87,pvtiaps};

void pvt(double T,double *p,double v,double *u,double *h,double *s,int
subst)
{pvtptr[subst-1](T,p,v,u,s); *h=(*u)+(*p)*v;
}
Nov 15 '05 #13
On Mon, 10 Oct 2005 18:35:45 +0000 (UTC), ro******@ibd.nrc-cnrc.gc.ca
(Walter Roberson) wrote:
In article <11**********************@g14g2000cwa.googlegroups .com>,
<ga*****@gmail.com> wrote:
I will re-state my problem. Name a C statement(s) that would certainly
make any compiler to generate indirect jmp instruction?
There is no such statement. C may be implimented on machines whose
processor lacks indirect branches.

That's certainly true.
On some architectures, with some compilers, with some code patterns,
C compilers have been known to generate indirect branches for some switch
statements.

(Also) On some architectures, possibly in all possibly in only some
cases, function return can be implemented using indirect jump.
- David.Thompson1 at worldnet.att.net
Nov 15 '05 #14

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

Similar topics

3
by: Hal Vaughan | last post by:
I'm not sure what the correct name for this would be. I'd think it's either an indirect reference, or a pointer, or something like that. I'm working on a program that would call a series of...
1
by: suresh | last post by:
Namasivayah, Stroustrup says when indirect array is used for reordering a valarray the index cannot be repeated twice(page 679). But Nicolai Josuttis in his book on C++ standard library, page...
2
by: Christopher Burns | last post by:
Hi all, We are using VB.NET (VS2K3), sitting on VSS6. I have sorted out a configuration problem that was preventing us from building from scratch for new developers, but now I am having a very...
1
by: James | last post by:
I am looking for a way to delete indirect children records when a root record is removed. The same action that occurs if you delete a directory that contains sub directories of sub directories. ...
1
by: Sam Phillips | last post by:
Howdy, I'm trying to apply color schemes to forms and subforms. I'm using a global function to change the colors/fonts of controls. Right now it correctly loops over the controls in the main...
0
by: Eric Barr | last post by:
I saw a small number of old threads about a strange build error, but never saw a solution. I just spent about 4 hours debugging this so i hoped i could help out people who come across this...
2
by: Zioth | last post by:
class A { function Get() {return $this;} } $obj = new A(); In php5, the following statement is valid: $x = $obj->Get()->Get(); In php4, I get the following error:
2
by: misogsk | last post by:
Hi all, can someone help with to handle this error: BC32206: Indirect reference is being made to assembly ? Code i used was written in ASP.NET 1.1 and I run it on ASP.NET 2.0. The error code:...
5
by: Rahul B | last post by:
Hi, I am having the following issues while trying to restrict the current user from creating any objects. Below is the privileges for the user and response when i try to create a table in that...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
Oralloy
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.