小编use*_*317的帖子

为什么距离是8而不是10?

所以我跟随http://insecure.org/stf/smashstack.html并偶然发现了一些我不太了解的事情:

Dump of assembler code for function main:
0x8000490 <main>:       pushl  %ebp
0x8000491 <main+1>:     movl   %esp,%ebp
0x8000493 <main+3>:     subl   $0x4,%esp
0x8000496 <main+6>:     movl   $0x0,0xfffffffc(%ebp)
0x800049d <main+13>:    pushl  $0x3
0x800049f <main+15>:    pushl  $0x2
0x80004a1 <main+17>:    pushl  $0x1
0x80004a3 <main+19>:    call   0x8000470 <function>
0x80004a8 <main+24>:    addl   $0xc,%esp
0x80004ab <main+27>:    movl   $0x1,0xfffffffc(%ebp)
0x80004b2 <main+34>:    movl   0xfffffffc(%ebp),%eax
0x80004b5 <main+37>:    pushl  %eax
0x80004b6 <main+38>:    pushl  $0x80004f8
0x80004bb <main+43>:    call   0x8000378 <printf>
0x80004c0 <main+48>:    addl   $0x8,%esp
0x80004c3 <main+51>:    movl   %ebp,%esp
0x80004c5 <main+53>:    popl   %ebp …
Run Code Online (Sandbox Code Playgroud)

x86 assembly byte

5
推荐指数
1
解决办法
202
查看次数

为什么在初始化此结构时需要更多大括号?

起初我尝试初始化这样的结构:

struct {
    char age[2];        // Hold two 1-Byte ages
} studage[] = {
    {23, 56},
    {44, 26}
};
Run Code Online (Sandbox Code Playgroud)

但这给了我一个关于缺少大括号的编译器警告,所以我使用了编译器建议的更多大括号,最后得到了这个:

struct {
    char age[2];        // Hold two 1-Byte ages
} studage[] = {
    {{23, 56}},
    {{44, 26}}
};
Run Code Online (Sandbox Code Playgroud)

没有警告.为什么我需要额外的牙套?

c struct

5
推荐指数
1
解决办法
215
查看次数

由于操作码和操作数无效组合,因此无法向右移动

section .data
shiftrightvalue db 4                     ; initialize shiftrightvalue to 4

section .bss

section .text
    global _start
    _start:
        mov ebx, 1111_1111b             ; copy 255 into ebx
        shr ebx, [shiftrightvalue]      ; shift the number in ebx 4 bits to the right to return the number 15 with the exit system call. ebx serves as the exit return value

    mov eax, 1                          ; specify linux system exit call
    int 80h                             ; execute the sys_call
Run Code Online (Sandbox Code Playgroud)

但是,如果我要组装,则会出现以下错误:

error: invalid combination of opcode and operands
Run Code Online (Sandbox Code Playgroud)

它指的是shr …

x86 assembly nasm

2
推荐指数
1
解决办法
524
查看次数

在声明/初始化结构时,每个花括号代表什么?(警告:初始化程序周围缺少大括号[-Wmissing-braces])

我遇到了以下结构:

static struct {
    unsigned char a[5];
} b[] = {       
        {1,1,1,1,1},
        {2,2,2,2,2}
};
Run Code Online (Sandbox Code Playgroud)

但是,如果正在编译,我会收到以下警告"警告:在初始化程序[-Wmissing-braces]周围缺少大括号".

如果我改变它:

static struct {
    unsigned char a[5];
} b[] = {       
        {{1,1,1,1,1}},
        {{2,2,2,2,2}}
};
Run Code Online (Sandbox Code Playgroud)

然后警告消失了.在"b [] ="之后,每个大括号代表什么?最里面的花括号显然是?代表char a [5]的初始化.但其他支撑是什么?明显?其他一个花括号必须考虑结构数组b [],但哪一个?为什么会出现第三个大括号,它代表什么呢?这让我很困惑.

c struct

1
推荐指数
1
解决办法
65
查看次数

标签 统计

assembly ×2

c ×2

struct ×2

x86 ×2

byte ×1

nasm ×1