2 czzcz czzcz 于 2014.09.10 15:58 提问

PC寄存器为什么会是负的?

最近在看一个叫Fiasco的微内核源码,遇到一个问题,请大神指点一下。如下是C/C++嵌入式的ARM汇编:

L4_INLINE void
l4_cache_op_arm_call(unsigned long op,
                     unsigned long start,
                     unsigned long end)
{
  register unsigned long _op    __asm__ ("r0") = op;
  register unsigned long _start __asm__ ("r1") = start;
  register unsigned long _end   __asm__ ("r2") = end;

  __asm__ __volatile__
    ("@ l4_cache_op_arm_call(start) \n\t"
     "mov     lr, pc                    \n\t"
     "mov     pc, %[sc]                    \n\t"
     "@ l4_cache_op_arm_call(end)   \n\t"
       :
        "=r" (_op),
        "=r" (_start),
        "=r" (_end)
       :
       [sc] "i" (L4_SYSCALL_MEM_OP),
        "0" (_op),
        "1" (_start),
        "2" (_end)
       :
        "cc", "memory", "lr"
       );
}

上面一段C/c++嵌入式汇编的大概意思是跳转到地址为L4_SYSCALL_MEM_OP的地方去执行,但是

#ifndef L4_SYSCALL_MAGIC_OFFSET
#  define L4_SYSCALL_MAGIC_OFFSET        8
#endif

#define L4_SYSCALL_MEM_OP        (-0x00000008-L4_SYSCALL_MAGIC_OFFSET)

L4_SYSCALL_MEM_OP是负值啊,这是什么情况?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!