Posts

Showing posts with the label machine language

Assembler and Machine Language

Image
Understanding machine language helps you becoming a better programmer because you understand how a computer really works. I have a German YouTube video where I show how to change a program after it has already been compiled: If you don't understand German or prefer a blog form that you can use for copy and pasting, stay here. I want to explain how to write a "hello world" C-program, translate it to assembler, machine language, find out what syscalls it does, and then debug it. We will use Ubuntu Linux for it. Let's start with the C program: #include <stdio.h> int main() {   printf("hello world"); } Compiled it: gcc -S hello.c This translated the C-code into assembler code, stored in hello.s: thorsten@ubuntu:~$ cat hello.s  .file "hello.c" .text .section .rodata .LC0: .string "hello world" .text .globl main .type main, @function main: .LFB0: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 ...