From the course: Advanced C Programming: Integrating C and Assembly Language

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Writing inline assembly

Writing inline assembly

- [Instructor] It's possible to use assembly inside your C source code file which removes the need to link separate modules. It's called inline assembly. The key is to use the asm keyword or one of its variations. This keyword is followed by a clutch of strings containing assembly language statements. These are assembled and their code is set into your program. This technique offers a quick way to optimize your code by throwing in a little assembly where necessary. In this code, you see an asm instruction at lines 13 through 18. This is an asm statement. The assembly code is contained in parentheses. Each line is enclosed in double quotes. The semi-colon at the end of each line is required. Line 14, configures the assembler, lines, 15, 16 and 17 contain assembly instructions. These instructions use the C language variable total. Now this variable is declared globally or external at line three. All C variables used with…

Contents