telecom • networking • design

an EventHelix.com blog


Leave a comment

Map C switch and if statements to assembly code

This article covers the code generation for if-else and switch statements.

Switch jump table

The code generated for a switch statement varies a lot from one compiler to another. In fact, a given compiler might generate different code in different scenarios. The choice of the code to be generated depends upon the number and range spread of individual case statements.

Different cases of generation of a switch statement are:


Leave a comment

Translate C for loop, while loop, struct access and array index into assembly

We have covered the C calling convention,  frame pointers and the assembly code in the previous article. This article will focus on the code generation for:

 

      C to assembly for loops, structure access and array indexing