Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Saturday, 1 June 2019

Assembly program in C

We can write an 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 the c program.

#include<stdio.h>  
void main() {  
   int a = 10, b = 20, c;  
     asm {  
      mov ax,a  
      mov bx,b  
      add ax,bx  
      mov c,ax  
   }  
   
   printf("c= %d",c);  
}  

Output:

c= 30

Note: We have executed this program on TurboC.

0 comments:

Post a Comment