register - ShenYj/ShenYj.github.io GitHub Wiki

寄存器

  • 可以通过 register read 查看通用寄存器

    (lldb) register read
    General Purpose Registers:
             x0 = 0x000000016f316f60
             x1 = 0x0000000000000000
             x2 = 0x000000013fe05b10
             x3 = 0x0000000000000000
             x4 = 0x0000000000000000
             x5 = 0x000000016f316dc0
             x6 = 0x0000000214f04e0c  
             x7 = 0x0000000000000400
             x8 = 0x0600000223fad2bf (0x0000000223fad2bf) (void *)0x00000223fad30800
             x9 = 0x0100000000000000
            x10 = 0x0600000223fad2bf (0x0000000223fad2bf) (void *)0x00000223fad30800
            x11 = 0x0700000223fad2bf (0x0000000223fad2bf) (void *)0x00000223fad30800
            x12 = 0x000000000000000a
            x13 = 0x000000013fd06c70
            x14 = 0x0000000000000000
            x15 = 0x0000000100af5330  (void *)0x0000000100af5308: AppDelegate
            x16 = 0x00000001e33afe4c  libobjc.A.dylib`objc_storeStrong
            x17 = 0x0000000226d2a570  (void *)0x00000001e33ab100: objc_release
            x18 = 0x0000000000000000
            x19 = 0x0000000000000000
            x20 = 0x000000013fe05b10
            x21 = 0x00000002148c270c  
            x22 = 0x0000000000000001
            x23 = 0x0000000000000000
            x24 = 0x0000000000000001
            x25 = 0x0000000000000000
            x26 = 0x00000002153a91a9  
            x27 = 0x000000002b870064
            x28 = 0x0000000000000010
             fp = 0x000000016f316f80
             lr = 0xca2abd8100aedfd0 (0x0000000100aedfd0) AssemblyTutorails`-[AppDelegate application:didFinishLaunchingWithOptions:] + 76 at AppDelegate.m:18
             sp = 0x000000016f316f40
             pc = 0x0000000100aedfd8  AssemblyTutorails`-[AppDelegate application:didFinishLaunchingWithOptions:] + 84 at AppDelegate.m:22:1
           cpsr = 0x60001000
    
    (lldb) 
    

其中

  • 通用寄存器

    • 64bit的: x0 - x28 (29个,每个64bit, 即8字节)
    • 32bit的: w0 - w28(属于0x - x28的低 32bit,即64bit的寄存器的一半空间低位部分)
    • x0 - x7 通常用来存放函数的参数,如果参数超出8个的数量,更多的参数使用堆栈来传递
    • x0 通常用来存放函数的返回值
  • 程序计数器

    • pc (Program Counter)
  • 堆栈指针

    • sp (Stack Pointer)
    • fp (Frame Pointer), 也就是 x29
  • 链接寄存器

    • lr(Link Register),也就是 x30
  • 程序状态寄存器

    • cpsr(Current Program Status Register)
    • spsr(Saved Program Status Register) 异常状况下使用
⚠️ **GitHub.com Fallback** ⚠️