# Unit 4.7 Question regarding jump directive

5 messages
Open this post in threaded view
|

## Unit 4.7 Question regarding jump directive

 This post was updated on . Question: What label would be the most descriptive replacement for WHAT_DOES_THIS_DO? My selection was: NOT_EQUAL_TO_0 The correct answer was: NOT_EQUAL_TO_1 I read this as, "If D-1 is not equal to 0, then jump". I was under the impression that all jump directives were predicated on the condition: "If [any comp designation in Hack language specification] to 0, then jump". What am I missing/misunderstanding?
Open this post in threaded view
|

## Re: Unit 4.7 Question

 This post was updated on . If D is 2, then D-1 = 1.  So it will jump, since 1 is nonzero. If D is 1, then D-1 = 0. So it will NOT jump. Since 0 is 0. If D is -1, then D-1 = -2.  So it will jump, since -2 is nonzero. So the jump only happens if D was not equal to 1. You are correct the computation has to be nonzero for the JNE jump to happen.  It's just that the only way the computation can be nonzero is if D happened to be anything other than 1 before the computation, in this specific case. [deleted my earlier bogus reply]
Open this post in threaded view
|

## Re: Unit 4.7 Question

 Administrator In reply to this post by ouverson You are asked to some up with the most descriptive label, not just a label that says what the next instruction does since, presumably, most people can look at the next instruction and see what it does. You want a label that conveys to the reader why it does it.