## Two-Plus-Two

<pre class="atari">
10 ;
20 ;ADDNRS.SRC
30 ;
40        *=$0600    ; Program begins at $0600
50 ;
52 ;  See notes below this snippet for details
54 ;
60        CLD        ; Clear Decimal Mode 
70 ADDNRS CLC        ; Clear Carry
80        LDA #2     ; Load Accumulator
90        ADC #2     ; Add w/Carry
100       STA $CB    ; Store Accumulator 
110       RTS        ; Return To Stack
120       .END       ; Program End Macro
</pre>

**Line 60:** Sets the 6502 to "binary" mode. the subsequent ADC command will then produce binary rather than BCD results. Basically, this just insures that we're in binary mode, just in case something previously has set us to decimal mode.

**Line 70:** The 6502 only has one "add" instruction, called ADC (Add With Carry). Since this instruction does carry operations, we need to make sure the carry bit is cleared first, in order to get a proper result.

**Line 80:** LDA can take either the value from an address location (signified with a '$', as in '$CB'), or it can take values passed to it immediately. That is done with the '#'. These values will be decimal, unless otherwise notated. 

**Line 90:** The immediate value 2 will be added to the value stored in the Accumulator, and the result will overwrite the Accumulator. The carry bit will be set appropriately.

**Line 100:** The value in the accumulator will be stored at the specified address location. In this case, the decimal value 4 (which is now in the Accumulator) will be stored at address location $CB. 

**Line 110:** This just basically resets the stack pointer. 

**Line 120:** This is a macro provided by the assembler software. In this case, it would either be Atari Assembler, or OSS Mac/65. 

Once assembled, you could use something like "Daves Debugger Tool" (DDT), to step through the program and inspect memory location $CB when the execution is complete. 

For a very thorough walk-through of this little program, you can [check out my video](https://rumble.com/v2in18e-atari-assembler-adding-2-2-the-winston-smith-demo.html?playlist_id=XhDRTzaWoOM). Skip to the 21 minute mark to just see the coding part.
