【问题标题】:Different representations for dot in binary二进制中点的不同表示
【发布时间】:2021-02-21 09:47:22
【问题描述】:

我有一个 C 代码,它简单地打印 hello world,就像这样

#include <stdio.h>

int main(void)
{
printf("Hello, world\n");
}

为了在 ubuntu 中编译代码,我使用了命令 make filename 这给了我这样的汇编代码:

    .text
    .file   "hello.c"
    .globl  main
    .align  16, 0x90
    .type   main,@function
main:                                   # @main
    .cfi_startproc
# BB#0:
    pushq   %rbp
.Ltmp0:
    .cfi_def_cfa_offset 16
.Ltmp1:
    .cfi_offset %rbp, -16
    movq    %rsp, %rbp
.Ltmp2:
    .cfi_def_cfa_register %rbp
    subq    $16, %rsp
    movabsq $.L.str, %rdi
    movb    $0, %al
    callq   printf
    xorl    %ecx, %ecx
    movl    %eax, -4(%rbp)          # 4-byte Spill
    movl    %ecx, %eax
    addq    $16, %rsp
    popq    %rbp
    retq
.Lfunc_end0:
    .size   main, .Lfunc_end0-main
    .cfi_endproc

    .type   .L.str,@object          # @.str
    .section    .rodata.str1.1,"aMS",@progbits,1
.L.str:
    .asciz  "Hello, world\n"
    .size   .L.str, 14


    .ident  "clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)"
    .section    ".note.GNU-stack","",@progbits

然后我使用 xxd -b hello 将其翻译成机器语言,这给了我(输出的子集

00000006: 00001010 00001001 00101110 01100110 01101001 01101100  ...fil
0000000c: 01100101 00001001 00100010 01101000 01100101 01101100  e."hel
00000012: 01101100 01101111 00101110 01100011 00100010 00001010  lo.c".
00000018: 00001001 00101110 01100111 01101100 01101111 01100010  ..glob
0000001e: 01101100 00001001 01101101 01100001 01101001 01101110  l.main
00000024: 00001010 00001001 00101110 01100001 01101100 01101001  ...ali
0000002a: 01100111 01101110 00001001 00110001 00110110 00101100  gn.16,

我的问题是:为什么(点“.”)在二进制中有不同的表示,就像在第一行和第四行我们有连续的点但表示不同?

我知道这是一个奇怪的问题,但这只是为了兴趣和知识,任何帮助将不胜感激

【问题讨论】:

  • 点代表任何不可打印的字符。它不是'.' ASCII 字符

标签: c assembly hexdump machine-language xxd


【解决方案1】:

这看起来像转储工具用点表示所有不可打印的字符。

有多个不可打印字符,所以有多个用点表示的二进制值。

【讨论】:

    猜你喜欢
    • 2018-04-10
    • 2016-05-01
    • 1970-01-01
    • 2017-06-16
    • 2013-05-02
    相关资源
    最近更新 更多