tags:

views:

304

answers:

2

Hi,

I'm doing some ASM code in a C code with the asm function.

My environment is DVL with gcc version 3.

Hi need to make a JMP to a relative address like %eip+0x1f.

How can I do this ?

Thanks

+2  A: 

x86 supports a short jump (JMP, opcode EB + 1 byte relative address) which should do what you want.

In most assemblers (including gcc's inline asm IIRC) you can just put a label where you want to jump to, and use jmp mylabel and let the assember figure out the correct opcode and relative address for the jump.

Charles Bailey
I've just tried this out in GCC, and it does work (jumping to labels). But you beat me to the post!
Michael Williamson
A: 

Are you using inline ASM? In gcc, using + in inline asm is illegal. Also, that syntax looks wrong to me.

Do some digging to look up the proper syntas for AT&T assembly. Which is what GNU uses.

Edit: Unless, of course, you'd rather use labels :)

David Titarenco