All for Joomla All for Webmasters

Assembly program in C

We can write assembly program code inside c language program. In such case, all the assembly code must be placed inside asm{} block.

Let’s see a simple assembly program code to add two numbers in c program.

  1. #include<stdio.h>
  2. void main() {
  3.    int a = 10, b = 20, c;
  4.    asm {
  5.       mov ax,a
  6.       mov bx,b
  7.       add ax,bx
  8.       mov c,ax
  9.    }
  10.    printf(“c= %d”,c);
  11. }

Output:

c= 30
PinIt
submit to reddit

Leave a Reply

Top