# Do these 2 codes do same thing?

 Classic List Threaded
7 messages
Reply | Threaded
Open this post in threaded view
|
Report Content as Inappropriate

## Do these 2 codes do same thing?

 //RAM[17] = 10 @17 M = 10 or //RAM[17] = 10 @10 D=A @17 M=D Thanks!
Reply | Threaded
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Do these 2 codes do same thing?

 This post was updated on . Conceptually, yes, they have the same end result. (Note that you cannot use a constant in the command M = 10.) Edit: correction below...
Reply | Threaded
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Do these 2 codes do same thing?

 But I see in Branching lecture, I see that @R1 M=0 or @R1 M=1 I'm a little confused about when I can use direct assignment vs indirect using "D".
Reply | Threaded
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Do these 2 codes do same thing?

 You are correct, and my original response is not accurate. I should have said "We can only use the literal constants 0 and 1." For all other constants, we must use an A instruction. Thank you for pointing out my error!
Reply | Threaded
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Do these 2 codes do same thing?

 Ah.. Thanks! I much appreciate it. :)
Reply | Threaded
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Do these 2 codes do same thing?

 Administrator You can also directly set A, D or M to -1. These are "C-instructions" (4.2.3)     dest=comp;jumpwhere the dest field is one or more of A, D or M, and the comp field is 0, 1 or -1. --Mark
Reply | Threaded
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Do these 2 codes do same thing?

 Somebody is getting rusty!
Loading...