简体   繁体   English

二进制点的不同表示

[英]Different representations for dot in binary

I have a code in C which simply prints hello world, like this我在 C 中有一个代码,它只是打印 hello world,就像这样

#include <stdio.h>

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

to compile the code in ubuntu I used the command make filename which gives me an assembly code like this:为了在 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

Which I then translated into machine language using xxd -b hello , which gives me ( subset of the output )然后我使用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,

My Question is: Why does the (dot ".") have different representations in binary like in the first and fourth lines we have consecutive dots but with different representations?我的问题是:为什么(点“.”)在二进制中有不同的表示,就像在第一行和第四行我们有连续的点但有不同的表示?

I know it's an odd question, but it's only for sake of interest & knowledge, any help would be appreciated我知道这是一个奇怪的问题,但这只是为了兴趣和知识,任何帮助将不胜感激

This looks like the dumping tool is representing all non-printable characters by dots.这看起来像转储工具用点表示所有不可打印的字符。

There are multiple non-printable characters, so there are multiply binary value that are represented by dots.有多个不可打印的字符,因此有多个由点表示的二进制值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用两个不同的二进制表示形式对有符号整数进行编程 - Program with two different binary representations for signed integers 将unsigned char转换为char将导致不同的二进制表示形式? - casting unsigned char to char would result in different binary representations? c中的二进制数字和字符串表示形式 - binary number and string representations in c 签名的二进制表示形式可以在体系结构之间移植吗? - Are signed binary representations portable between architectures? C - 二进制和十六进制表示之间的快速转换 - C - Fast conversion between binary and hex representations 通过附加两个int的二进制表示来创建double - Create double by appending binary representations of two ints 如何交换无符号整数的两个八位二进制表示形式的位置? - How to swap places of a two eight-bit binary representations of an unsigned integer? 以下是什么意思。 C 语言中带符号类型的二进制表示? - What does the following mean wrt. binary representations of signed types in C language? 如何知道两种方法是否对相同数据的不同表示做相同的事情 - How to know if two methods do the same thing on different representations of the same data 如何找到2个不同向量的点积? - How to find the dot proudct of 2 different vectors?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM