in CO and Architecture
15,863 views
1 vote
1 vote
how many number of times the instruction sequence below will loop before coming out of the loop?

             MOV AL,00H

  A1:       INC AL

             JNZ A1

a)1

b)256

c)255

d)will not come out of the loop
in CO and Architecture
by
15.9k views

2 Answers

1 vote
1 vote
MOV AL,00H--- means 0000 0000(binary) is loaded into the register AL. Register AL is of 8 bits (Intel x86 architecture).

Now in each loop the value of AL is incremented by one.....this will go on till AL value becomes 1111 1111(binary) i.e 255(decimal).

After this when it is incremented i.e 1111 1111 + 0000 0001= 10000 0000. Now this is an overflow as AL is of 8 bits. The MSB is discarded(the carry out) and hence AL becomes 0000 0000 again. Therefore, it comes out of the loop.

Totally it will loop= 255 + 1(for the last calculation) = 256

Hence B is the correct option

PS: 8085 is out of GATE syllabus now
0 votes
0 votes
INC AL happens first for 00
happens second for 01
.....
happens 256th time for FF

and the loop terminates
by

3 Comments

Sir, is my explanation correct?
0
0
yes. Except the reason for AL being 8 bits- AL is 8 bits is not due to data being moved there. It is fixed by the architecture.
0
0
Ok sir I got it....as in the question they didnt mention anything about the architecture thats y i assumed it to be 8 bits.....
0
0

Related questions

0 votes
0 votes
3 answers
2
anonymous asked in Algorithms Jun 14, 2017
1,199 views
anonymous asked in Algorithms Jun 14, 2017
by anonymous
1.2k views