0

This program in not working, the number that needs to be diplayed on the leds in EA.

;program to count the number of odd bytes in memory from address 0xff00 to 0xffff.
;number is to be displayed on 8 leds

;set up for leds and hardware
prog    equ     $2000

PORTB   equ     $0001
DDRB    equ     $0003
PTP     equ     $0258
DDRP    equ     $025A
PTJ     equ     $0268
DDRJ    equ     $026A

        org     prog
        bset    DDRP,#$0F
        bset    PTP,#$0F
        bset    DDRJ,#$02
        bclr    PTJ,#$02
        bset    DDRB,#$FF
        


        ldx     $ff00  ; load contents of ff00 to x
	ldaa    0    ;initialize a to 0

check:  brset   1,x+,$01,loop;AND contents of X with $01, increment x,branch to loop if result = 0
        bra     check
loop:   inca         ;increment accumulator a
        cpx     $FFFF  ;compare contents of x w/ contents of address ffff
        beq     done ;end is reached
        bne     check; more to do
done:   staa    PORTB  ; store contents of a to PORTB
        swi
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Salem
0

> brset 1,x+,$01,loop;AND contents of X with $01, increment x,branch to loop if result = 0
You're counting run-lengths of odd numbers then.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.