【问题标题】:Basic GCC inline assembly question基本的 GCC 内联汇编问题
【发布时间】:2010-10-01 13:25:44
【问题描述】:

我想将变量“userstack”的值移动到 ESP 寄存器中,然后绝对跳转到变量“location”中包含的内存地址。 这就是我所拥有的:

// These are the two variables that contains memory addresses
 uint32_t location = current_running->LOCATION;
 uint32_t userstack = current_running->user_stack;

 // And then something like this
 __asm__ volatile ("movl userstack, %esp");
 __asm__ volatile ("ljmp $0x0000, location");

但是,当我尝试编译时,我得到了错误: “错误:后缀或操作数对 ljmp 无效”和“未定义对 `userstack' 的引用”。

非常感谢任何帮助。

【问题讨论】:

    标签: gcc inline-assembly


    【解决方案1】:

    看看manual

    我认为你需要这样的东西:

    asm volatile ("movl %0, %esp" : "g" (userstack));
    asm volatile ("ljmp $0x0000, %0" : "g" (location));
    

    基本上 GCC 需要知道用户栈和位置可能是什么和位置(寄存器、内存操作数、浮点数、受限制的寄存器子集等),并且由“g”指定,在这种情况下表示通用操作数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多