6502 EXAMPLE 2


Example 2

8-Bit Addition
Purpose: Add the contents of memory locations 0040 and 0041, and place the result in memory
location 0042.
Sample Problem:
             (0040) = 39
             (0041) = 2B
Result: (0042) = 64
Source Program:

.ORG  0  
LDA #$39
STA     $40
LDA  #$2B
STA     $41
CLC             ;CLEAR CARRY TO START 
LDA $40     ;GET FIRST OPERAND 
ADC $41     ;ADD SECOND OPERAND 
STA  $42      ;STORE RESULT 
BRK


After you compile you will see the new value of memory location $42 is 64. 

No comments:

Post a Comment