Digital Electronics - The 8051 Microcontroller - Discussion
Discussion Forum : The 8051 Microcontroller - General Questions (Q.No. 2)
2.
This program code will be executed continuously:
STAT: | MOV A, #01H |
JNZ STAT |
Discussion:
18 comments Page 1 of 2.
Ramesh Maddara said:
5 years ago
8051:
It doesn't have Z flag. Accumulator value is checked for Zero or non-Zero.
In this case, 0x01 is non-Zero and hence loop continues forever.
The answer is TRUE.
8085: Same instructions in 8085 works differently since it has Z flag which affects for Arithmetic or Logical Operations.
No flags are affected for a data transfer since it doesn't happen inside the ALU, and hence the value of Zero Flag depends on the previous Arithmetic or Logic instruction which is not known here, so let us assume Z flag = 1 on reset.
Right Answer in case of 8085: Unknown (FALSE may be the best answer if we consider the given TRUE/FALSE choices).
It doesn't have Z flag. Accumulator value is checked for Zero or non-Zero.
In this case, 0x01 is non-Zero and hence loop continues forever.
The answer is TRUE.
8085: Same instructions in 8085 works differently since it has Z flag which affects for Arithmetic or Logical Operations.
No flags are affected for a data transfer since it doesn't happen inside the ALU, and hence the value of Zero Flag depends on the previous Arithmetic or Logic instruction which is not known here, so let us assume Z flag = 1 on reset.
Right Answer in case of 8085: Unknown (FALSE may be the best answer if we consider the given TRUE/FALSE choices).
Kishor said:
5 years ago
Agree @Anamika.
Zero flags won't be affected & hence JNZ condition will fail & loop should terminate. Since MOV A, #01 is a data transfer instruction & as we know data transfer instructions do not affect flags.
Zero flags won't be affected & hence JNZ condition will fail & loop should terminate. Since MOV A, #01 is a data transfer instruction & as we know data transfer instructions do not affect flags.
Nayan said:
6 years ago
JNZ is jump if accumulator is not zero.
Here accumulator contain non-zero value, so it will be a continuous loop execution.
Here accumulator contain non-zero value, so it will be a continuous loop execution.
Vignesh said:
6 years ago
Here, JNZ is jumping on no-zero so A value is 1.
It's goto STAT.
It's goto STAT.
Siddu said:
8 years ago
How it is possible ? Because there is no continuous loop.
Anamika dadhich said:
10 years ago
How is this possible?
Jmp instructions does not work after data transfer instruction. Then how will the loop run infinitely?
Jmp instructions does not work after data transfer instruction. Then how will the loop run infinitely?
Edison said:
1 decade ago
First instruction is a constant value with 01h so, it will never be zero hence it always jumps.
Soumya said:
1 decade ago
Jump to relative address, if A is not zero, since A is not zero so it jumps to STAT. Continues the loop.
Abc said:
1 decade ago
JNZ means Jump if Non Zero.
Ramu said:
1 decade ago
jNZ instruction checks the Contents of Accumulator(A) register.
it's value is greater than zero every time... because it is not decrmenting. So, the loop will infinitely repeats...
it's value is greater than zero every time... because it is not decrmenting. So, the loop will infinitely repeats...
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers