Assembly Language Programming in C Programming Language


(1)What will be output of following c program?
void main()
{
clrscr();
asm{
         mov ax,61;
         mov bx,10;
         add bx,ax;
    }
printf("\n%d",_BX);
getch();
}

(a)61
(b)10
(c)71
(d)0

(2)What will be output of following c program?
void main()
{
clrscr();
asm{
         mov ax,10;
         mov bx,20;
         mov cx,30;
         add ax,bx;
         sub ax,cx;
     }
printf("%d",_AX);
getch();
}
(a)-20
(b)0
(c)20
(d)-10

(3)What will be output of following c program?
void main()
{
clrscr();
asm{
         mov ax,10;
         mov bx,20;
         mov cx,30;
         add ax,bx;
         add bx,cx
   }
printf("%d  %d   %d",_AX,_BX,_CX);
getch();
}
(a)30 50 30
(b)10 20 30
(c)10 30 60
(d)30 20 10
(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();
}
(a)5
(b)10
(c)15
(d)Compiler error

(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();
}

(a)5
(b)4
(c)9
(d)Compiler error

(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();
}

(a)45
(b)48
(c)60
(d)Compiler error

(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();
}

(a)24 23 22 21 20
(b)24 23 22 21
(c)20
(d)Compiler error

(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();
}

(a)5
(b)10
(c)15
(d)20

(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();
}

(a)-15 2
(b)15 -15
(c)15 -16
(d)-16 2

(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();
}
(a)10
(b)20
(c)30
(d)Infinite loop


(1)
Answer: (c)
Explanation:
ax and bx is general purpose register.
Statement mov ax, 61 means value 61 is storing at register ax.
Statement add bx,ax means 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)
Answer: (b)
Explanation:
Same concept has used as in question 1.
Mnemonic sub means subtraction.
(3)
Answer: (a)
Explanation:
Same concept has been used as in question 1.
(4)
Answer: (d)
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)
Answer: (a)
Explanation:
Mnemonic div means division of its operand with content of accumulator i.e. ax.
Meaning of div bx means 15/3.
(6)
Answer: (c)
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)
Answer: (c)
Explanation:
dec dx means decrease the content of register dx by one.
(8)
Answer: (a)
Explanation:
Mnemonic or means bitwise OR operations between its operands.
(9)
Answer: (d)
Explanation:
Mnemonic and means bitwise AND operations between its operands.

(10)
Answer: (b)
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.

0 comments:

Post a Comment