*
*
*               SUM LOOOP
*               sum = 0
*               x = 0
*               while (x <=10)
*               {
*                       sum = sum + x
*                       x++
*               }

*LABEL          OPER.   OPERAND         COMMENT
*****           *****   *******         *******************************

RAMStart        EQU     $0040           ; Starting location of RAM
ROMStart        EQU     $8000           ; Starting location of ROM (FLASH)
ResetVector     EQU     $FFFE           ; Reset vextor address
LOOPMAX         EQU     $05

                ORG     Resetvector
                FDB     MAIN


                ORG     RAMStart
TEMP            RMB     1               ; Reserve 1 memory bytes



                ORG     ROMStart

                ; Add last bytes
MAIN            LDA    #$00             ; Load AC with 0; Sum
                LDX    #$00             ; Load X with 0; Index counter
          

LOOP            INCX                    ; Increment X
                STX    TEMP             ; Store X to TEMP
                ADD    TEMP             ; Add TEMP to AC
                CPX    #LOOPMAX         ; Compare X with LOOPMAX
                BLT    LOOP             ; Branch lower (less than) to LOOP
                

                NOP
                NOP



