Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   indirect jmp (http://www.velocityreviews.com/forums/t439733-indirect-jmp.html)

ganeshb@gmail.com 10-10-2005 06:01 AM

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


Walter Roberson 10-10-2005 06:09 AM

Re: indirect jmp
 
In article <1128924079.590340.203780@g14g2000cwa.googlegroups .com>,
<ganeshb@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!

Keith Thompson 10-10-2005 08:37 AM

Re: indirect jmp
 
ganeshb@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) kst-u@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.

SM Ryan 10-10-2005 09:21 AM

Re: indirect jmp
 
ganeshb@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.

ganeshb@gmail.com 10-10-2005 03:35 PM

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


Flash Gordon 10-10-2005 04:26 PM

Re: indirect jmp
 
ganeshb@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.

ganeshb@gmail.com 10-10-2005 05:16 PM

Re: indirect jmp
 
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


Flash Gordon 10-10-2005 06:28 PM

Re: indirect jmp
 
ganeshb@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.

Walter Roberson 10-10-2005 06:35 PM

Re: indirect jmp
 
In article <1128964569.256449.218690@g14g2000cwa.googlegroups .com>,
<ganeshb@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.

Kenneth Brody 10-10-2005 07:27 PM

Re: indirect jmp
 
ganeshb@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:ThisIsASpamTrap@gmail.com>



All times are GMT. The time now is 01:53 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.