## INDEX

### Assembly language program in c programming language

Assembly language program in c programming language.

(1) What will be output of following c program?

void main()

{

clrscr();

asm{

mov ax,61;

mov bx,10;

}

printf("\n%d",_BX);

getch();

}

Output: 71

Explanation: ax and bx is general purpose register.

Statement  mov ax,61 means value 61 is storing at register ax.

Statement add bx,ax meand addition of content of register bx i.e 10 and content of register ax i.e 61 and result of addition is storing at register bx.

(2) What will be output of following c program?

void main()

{

clrscr();

asm{

mov ax,10;

mov bx,20;

mov cx,30;

sub ax,cx;

}

printf("%d",_AX);

getch();

}

output: 0

Explanation : same concept as in question 1.

Mnemonic sub means subtraction.

(3) What will be output of following c program?

void main()

{

clrscr();

asm{

mov ax,10;

mov bx,20;

mov cx,30;

}

printf("%d  %d   %d",_AX,_BX,_CX);

getch();

}

output: 30 50 30

Explanation : same concept as in question 1.

(4) What will be output of following c program?

void main()

{

clrscr();

asm{

mov ax,10;

mov cx,20;

inc cx;

div 2;

}

printf("%d ",_AX);

getch();

}

output: Compile time error

Explanation :

Mnemonic inc means increment content of register by one.

Mnemonic div means division with ax.

Operand of div must be a register not a value.

Note. Register ax is known as accumulator.

(5) What will be output of following c program?

void main()

{

clrscr();

asm{

mov ax,15;

mov cx,12;

mov bx,3;

div bx;

}

printf("%d ",_AX);

getch();

}

output: 5

Explanation:

Mnemonic div means division of its operand with content of accumulator i.e ax.

Meaning of div bx means 15/3.

(6) What will be output of following c program?

void main()

{

clrscr();

asm{

mov ax,15;

mov bx,3;

inc bx;

mul bx;

}

printf("%d ",_AX);

getch();

}

output: 60

Explanation:

Mnemonic mul means multiplication of its operand with content of accumulator i.e ax.

Meaning of mul bx means 15*4.

Note: inc bx means increase the content of register bx by one.

(7) What will be output of following c program?

void main()

{

int i=0;

clrscr();

asm mov dx,25;

for(i=0;i<5;i++)

asm dec dx;

printf("%d ",_DX);

getch();

}

output: 20

Explanatio:

dec dx means decrese the content of register dx by one.

(8) What will be output of following c program?

void main()

{

int j=5;

asm mov cx,10;

clrscr();

asm OR cx,j;

printf("%d ",_CX);

getch();

}

output: 5

Explanation:

Mnemonic or means bitwise OR operations between its operands.

(9) What will be output of following c program?

void main()

{

clrscr();

asm {

mov ax,15;

mov dx,2;

and dx,ax;

not ax;

}

printf("%d %d ",_AX,_DX);

getch();

}

output: -16 2

Explanation:

Mnemonic and means bitwise AND operations between its operands.

(10) What will be output of following c program?

void main()

{

clrscr();

asm mov ax,15;

asm mov bx,5;

india:

asm inc ax;

asm dec bx;

asm jnz india;

printf("%d ",_AX);

getch();

}

output: 20

Explanation:

Statement jnz India means jump to label india till content of last register i.e bx is not zero. When content of register bx became zero then stop the jumping.

(11) What will be output of following c program?

void main()

{

clrscr();

asm mov ax,15;

asm mov bx,1;

india:

asm xor ax,5;

asm dec bx;

asm jz india;

printf("%d ",_AX);

getch();

}

output: 15

Explanation:

Statement jz India means jump to label india till content of last register i.e bx is zero. When content of register bx became not zero then stop the jumping.