in CO and Architecture
1,224 views
1 vote
1 vote

I am getting 37.

in CO and Architecture
1.2k views

3 Comments

How 37? I think it should be 19. They are asking about how many time it is RESET - means for how many times its value will be 0. Please note that the zero flag is SET if some register value comes to be zero as a result of some arithmetic operation. Here R2 seems to be the only register which may result in a value of zero after 19 times of the loop iteration.
0
0
Zero flag value get affected after every arithmetic operation. In the above question, we have two arithmetic instructions.
3
3
edited by
Yes $37$ seems correct. $19$ for ADD and $18$ for DCR
2
2

1 Answer

1 vote
1 vote

It should be 18 .

Zero Flag (Z) – After any arithmetical or logical operation if the result is 0 (00)H, the zero flag becomes set i.e. 1, otherwise it becomes reset i.e. 0.

(23) base 8 = 19 in dec​​​​​​imal 

Add R1 + R2 = 19

DCR R2 = 19 -1 = 18 

Now it enters into the loop . 

As 18 != 0 again execution goes to ADD R2, R1 ( R1 = 0 , R2 = 18 )

so after execution R2 = 17  and again enter into the loop . like it will continue until it will not 0  

Related questions