Hacker News new | ask | show | jobs
by sigjuice 3347 days ago
I would suggest reading the first couple of pages of any compiler book. e.g. https://books.google.com/books?id=_tgh4bgQ6PAC&printsec=fron...

Compilers are computer programs that translate a program written in one language into a program written in another language.

Example of a compiler in action.

  $ cat hello.c
  #include <stdio.h>
   
  int main(void)
  {
          printf("hello world\n");
   
          return 42;
  }

  $ cc -O3 -S hello.c -o -
          .section	__TEXT,__text,regular,pure_instructions
          .macosx_version_min 10, 12
          .globl	_main
          .align	4, 0x90
  _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
          leaq	L_str(%rip), %rdi
          callq	_puts
          movl	$42, %eax
          popq	%rbp
          retq
          .cfi_endproc
   
          .section	__TEXT,__cstring,cstring_literals
  L_str:                                  ## @str
          .asciz	"hello world"
   
   
  .subsections_via_symbols