Program to add odd numbers in an array.

prog:   equ     $0800
data:   equ     $0900

array:  equ     $E000
len:    equ     $20

CODE:   section .text
        org     prog

        ldx     #array                  ; initialize pointer
        ldy     #0                      ; initialize sum to 0
loop:   ldab    0,x                     ; get number
        brclr   0,x,$01,even            ; check to see if even
        aby                             ; odd - add to sum
even:   inx                             ; point to next entry
        cpx     #(array+len)            ; more to process?
        blo     loop                    ; if so, process
        sty     answer                  ; done -- save answer

DATA:   section .data
        org     data
answer: ds.w    1               ; reserve 16-bit word for answer