Click to Answer GATE Question of the Day

Like and Get GATE 2013 Updates on your facebook

One of the Solved question of GATE 2011

An 8085 assembly language program is given below. Assume that the carry flag is initially unset. The content of the accumulator after the execution of the program is

MVI A,07H

RLC

MOV B,A

RLC

RLC

ADD B

RRC

Options  : (A) 8CH  (B) 64H  (C) 23H  (D) 15H

Listen question:
This is 8085 microprocessor (some times they may ask 8086 also). In this question is interested about Accumulator after execution. Initially the carry flag is reset (its 0 ).

Little theory about this:
8085 is 8 bit microprocessor. The flag format is

s - sign flag, z – zero flag, AC – Auxiliary carry flag, p –parity flag, cy – carry flag(this is the flag interested ).

cy – carry flag will be affect when doing the arithmetic operation, its mean if we have the order of the format of 8 bit is D7 D6 D5 D4 D3 D2 D1 D0 then after doing the arithmetic operation the D7 bit will be greater than or equal to 10(one zero). So this is called the Carry flag affected.

Instruction functionality :

MVI A,07H --à ; (H-- hexa decimal, D--Decimal )(07H = 07D) so 07H moves to Accumulator Immediately. (immediately functions using only when the raw data moves into the register)

RLC : --àThe contents of the accumulator are rotated left one position. Bit D7 is placed in both D0 and CY. This CY flag is modified according to bit D7. S,Z,P and AC are not affected.

RRC: -àThe content of the accumulator are rotated right by 1 bit. Bit D0 is placed in both D7 and CY at the same time.

MOV B,A: -àthe content of the accumulator Register moves to the B register. No flags will be affected.

ADD B : -àAdd the B register content to accumulator register. All flags are affected based upon the result of the addition.

Program explanation:

MVI A,07H ; a=07h

RLC ; 00000111 will become a=00001110, cy=0

MOV B,A ; b=00001110 (b=0Eh)

RLC ; a=00011100, cy=0

RLC ; a=00111000, cy=0

ADD B ; before execution of this instruction a=38H, b=0Eh; after execution of this instruction a+b = 46H, so in accumulator = 46H(01000110)

RRC ; a=00100011(23H), cy=0

After this RRC instruction content of the accumulator is a=23H

So answer is (C)

0 comments:

Your reply for One of the Solved question of GATE 2011