Translate C code to assembly language

Translate C code to assembly language

Learn about mapping C function calls, loops and conditional statements to assembly

Image for post

Mapping from C to generic assembly code

Learn the basics of mapping from C to a generic assembly language. The following links cover:

  • C function call and stack frame management for keeping track of parameters and local variables
  • Code generated for while loops, for loops and structure access
  • Assembly code for handling conditional statements in C

Anatomy of a C Function Call: Frame Pointer and the Stack

Describes a C function call at assembly level. Frame pointer based access to local variables and parameters is?

www.eventhelix.com

C to Assembly: For and While Loop, Structure and Array Access

Describes assembly code generation for while loop, for loop, structure access and array indexing.

www.eventhelix.com

C to Assembly: If-Else and Switch Statement Code Generation

Understand how the if-else and switch statements are implemented in assembly language.

www.eventhelix.com

x86 assembly basics

The following video covers the basics on x86 assembly language.

  • Understand the basic register set on x86 processors.
  • Learn how a stack frame is managed.
  • Learn assembly language basics with move, add, sub, push, pop, lea (load effective address), cmp, jmp, call, leave and return

Understanding the x86 assembly code generated from a C program

The following video maps a C program that calculates Fibonacci numbers into x86 assembly code. You will learn:

  • Accessing local variables with address offsets from the base pointer register (rbp)
  • Passing parameters to a function via the stack
  • Calling a C function.
  • Removing the parameters from the stack.
  • Implementing a while loop in assembly.
  • Performing arithmetic operations.

Use the interactive online compiler to high level languages like C, C++ into assembly

Compare the assembly code generated from high level languages for different compilers and processor architectures using the Compiler Explorer.

Compiler Explorer

Compiler Explorer is an interactive online compiler which shows the assembly output of compiled C, C++, Rust, Go, D?

godbolt.org

25