Program to Read Port B, Write Result to Port A
; Program which reads Port B, writes value read to Port A
PROG: equ $0800
STACK: equ $0A00
PORTA: equ $0000
PORTB: equ $0001
DDRA: equ $0002
DDRB: equ $0003
CODE: section .text
org PROG
lds #STACK ; initialize stack pointer
ldaa #$FF ; Make Port A output -- 0xFF -> DDRA
staa DDRA
clr DDRB ; PORTB input -- 0x00 -> DDRB
loop: ldaa PORTB ; Get switch state
staa PORTA ; Write to Port A
jsr delay ; Wait a while
bra loop ; Repeat
; Subroutine to wait for 10 ms
delay: psha
pshx
ldaa #25
loop2: ldx #800
loop1: dex
bne loop1
deca
bne loop2
pulx
pula
rts