Question
Download Solution PDFAssuming carry flag is initially '0' and both registers A and B has values 50 H, how many times the NOP instruction will be executed if following code is executed in 8085 microprocessor?
BACK : NOP
ADD B
RLC
JNC BACK
HLT
Answer (Detailed Solution Below)
Detailed Solution
Download Solution PDFConcept:
This problem involves understanding the effect of the ADD
, RLC
(Rotate Left), and JNC
(Jump if No Carry) instructions on the accumulator (register A) and the carry flag in the 8085 microprocessor.
Given:
Initial values:
A = 50H = 0101 0000 (binary)
B = 50H
Carry flag = 0
Code Execution:
Label: BACK → NOP
Just a No Operation instruction. It is executed every time the loop begins.
ADD B
A = A + B = 50H + 50H = A0H = 1010 0000 (binary)
Carry flag remains 0 because sum is within 8-bit range (≤ FFH)
RLC (Rotate Left Accumulator)
A = A0H = 1010 0000
RLC rotates bits left and MSB goes to LSB and also to Carry.
So: 0100 0001 = 41H
Carry = MSB of A0H = 1
Now A = 41H, Carry = 1
JNC BACK
This instruction jumps to BACK only if Carry = 0.
But Carry = 1 now, so it will NOT jump, and proceeds to next instruction.
HLT
Halts the program.
Conclusion:
Since the loop was executed only once before carry became 1, the NOP
instruction is executed only once.
Last updated on May 30, 2025
-> The ISRO Technical Assistant recruitment 2025 notification has been released at the official website.
-> Candidates can apply for ISRO recruitment 2025 for Technical Assistant from June 4 to 18.
-> A total of 83 vacancies have been announced for the post of Technical Assistant.
-> The Selection process consists of a written test and a Skill test.
-> Candidates can also practice through ISRO Technical Assistant Electrical Test Series, ISRO Technical Assistant Electronics Test Series, and ISRO Technical Assistant Mechanical Test Series to improve their preparation and increase the chance of selection.