Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7836475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:10:39+00:00 2026-06-02T14:10:39+00:00

I wrote a small program to test GCC’s options. int main() { int a=0;

  • 0

I wrote a small program to test GCC’s options.

int main()
{
    int a=0;
    __asm__("movl %0,%%ecx\n"
            "jmp jmpsection\n"
            "inc %%ecx\n"
            "jmpsection: movl $1,%%eax\n"
            "movl $0,%%ebx\n"
            "int $0x80\n"::"a"(a):"ecx","ebx");
}

In order to keep var a equal to 1, skip the inc instruction.
I want to force GCC to generate the jmp instruction using IP relative addressing method.
I have searched the GCC manual to find a solution, but I feiled.
Thanks for replay.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:10:40+00:00Added an answer on June 2, 2026 at 2:10 pm

    For the x86, IP relative addressing is only possible in long mode (64 bit) and you seem to be writing 32 bit code.

    Edit: Actually, in 32 bit mode it is possible to make jumps relative to the current IP and I think the compiler actually generates the correct code in your case. Let’s take a look at the relevant part of the generated assembly:

    00000000 <main>:
      ...
      13:   eb 01                   jmp    16 <jmpsection>
      15:   41                      inc    %ecx
    
    00000016 <jmpsection>:
      16:   b8 01 00 00 00          mov    $0x1,%eax
      ...
    

    So, although it looks like the instruction at address 13 makes a direct jump to address 16, it actually is an IP relative jump. Take a look at the machine code:

    eb 01
    

    eb is the opcode for a short jmp with an 8-bit displacement. 01 is this displacement. The result of this instruction is a jump to %eip + 0x01 and, as the IP points to the next instruction to be executed, this will jump to address 16.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this small C++ program and built it(Release) #include<iostream> int main(){ std::cout<<Hello World;
I wrote a small program to test accessing a widget parent's slot. Basically, it
Here's a small test program I wrote: #include <iostream> using namespace std; class A
I wrote a small program in VS2005 to test whether C++ global operator new
I wrote a small test program with a sample class containing also self-defined constructor,
I wrote a small program to test out Textmate 2 (I'm fairly new to
I wrote a small program, that creates files at an interval of 1 minute.
So I wrote a project-management program for a small business using Microsoft Access 2007.
I wrote a small program using a custom indexOf function but wanted to dismiss
I wrote a small program that uses Mechanize to traverse a site. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.