Add Two Numbers Using Inline Assembly Language ???
#include<stdio.h> void main() { int a=3,b=3,c; asm { mov ax,a mov bx,a add ax,bx mov c,ax } printf("%d",c); }
- Assembly Language can be Written in C .
- C Supports Assembly as well as Higher Language Features so called“Middle Level Language”.
- As shown in above Program , “asm” Keyword is written to indicate that“next followed instruction is from Assembly Language”.
asm mov ax,a
- Opening Curly brace after “asm” keyword tells that it is the “Start of Multiple Line Assembly Statements” i.e “We want to Write Multiple Instructions”
- Above Program Without “Opening and Closing Brace” can be written as – ["asm" keyword before every Instruction ]
asm mov ax,a asm mov bx,a asm add ax,bx asm mov c,ax
What above Program Actually Does ?
- In 8086 Assembly Program for Storing Values AX,BX,CX,DX registers are used called General Purpose Registers .
asm mov ax,a
- Move Instruction Copies content of Variable “a” into Register “AX”
- Add Instruction adds Content of two specified Registers and Stores Result in “ax” in above example.
- Copy Result into Variable “c”
No comments:
Post a Comment