0

我在 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,

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

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

4

1 回答 1

6

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

有多个不可打印字符,因此有多个由点表示的二进制值。

于 2020-11-09T13:06:50.373 回答