ARM base instruction -- sbfiz

时间:2024-10-01 07:49:16

Signed Bitfield Insert in Zeros copies a bitfield of <width> bits from the least significant bits of the source register to bit position <lsb> of the destination register, setting the destination bits below the bitfield to zero, and the bits above the bitfield to a copy of the most significant bit of the bitfield.

带符号的位字段零插入将<width>位的位字段从源寄存器的最低有效位复制到目标寄存器的<lsb>位位置,将位字段下方的目标位设置为零,并将位字段上方的位设置为位字段最高有效位的副本。

32-bit variant
    SBFIZ <Wd>, <Wn>, #<lsb>, #<width>

    is equivalent to
    SBFM <Wd>, <Wn>, #(-<lsb> MOD 32), #(<width>-1)

64-bit variant
    SBFIZ <Xd>, <Xn>, #<lsb>, #<width>

    is equivalent to
    SBFM <Xd>, <Xn>, #(-<lsb> MOD 64), #(<width>-1)

  40380c:    937d7f80     sbfiz    x0, x28, #3, #32    // x28=1, x0=1<<3=8
  403810:    97fff8dc     bl    401b80 <malloc@plt>     // malloc(x0)
  403814:    f9002660     str    x0, [x19, #72]          // this->argv=malloc
  403818:    aa0003fb     mov    x27, x0
  40381c:    b4000b20     cbz    x0, 403980 <ferror@plt+0x1aa0>  // exit(1)
        if (!(this->argv = malloc(sizeof(char *) * this->argc))) {
            // cbz 403980
            perror("malloc");
            exit(1);
        }


=> 0x000000000040380c:  80 7f 7d 93     sbfiz   x0, x28, #3, #32
1: $sp = (void *) 0x7fffffb190
(gdb) p/x $x0
$65 = 0xc
(gdb) p/x $x28
$66 = 0x1
(gdb) n
0x0000000000403810 in ?? ()
=> 0x0000000000403810:  dc f8 ff 97     bl      0x401b80 <malloc@plt>
1: $sp = (void *) 0x7fffffb190
(gdb) p/x $x0
$67 = 0x8
(gdb) p/x $x28
$68 = 0x1