Search code examples
cassemblyhexdumpmachine-codexxd

Different representations for dot in binary


I have a code in C which simply prints hello world, like this

#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:

    .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)

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


Solution

  • 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.