include "equ_1000.s" ;Equates for all 68HC11 internal registers
*********** Begin System Initialization ***********
org $F800 ;EEPROM starts at F800h
START lds #00FF ;Initialize stack in RAM at 00FFh
jsr SETTLE ;Delay routine lets internal regs/system settle
ldx #$1000 ;IX <--- $1000 (index = $1000 for addressing)
ldaa #$FF ;ACCA <--- 1111 1111
staa ddrd,x ;Port D configured for output
ldaa #%11101111
staa pioc,x ;STRB set for simple handshake and active high
*********** End System Initialization ***********
*********** Begin Main Program ***********
MAIN clr portd,x ;Set Port D to Latch 1
ldy #0007 ;IY <--- 7
NXTLAT clra ;ACCA <--- 0
staa portb,x ;Clear current latch
ldab #$07 ;ACCB <--- 7
ldaa #$01 ;ACCB <--- 1
staa portb,x ;Current latch <--- ACCA
jsr ONESEC ;Go to one second delay routine
NXTPIN lsla ;Go to the next port pin
staa portb,x ;Test latch pin
jsr ONESEC ;Go to one second delay routine
decb ;ACCB <--- ACCB - 1
bne NXTPIN ;ACCB <> 0 then test next latch pin
clra ;ACCA <--- 0
staa portb,x ;Clear current Latch
inc portd,x ;Control next Latch
dey ;IY <--- IY - 1
bne NXTLAT ;IY <> 0 then test next latch else go to start
jmp MAIN
*********** End Main Program ***********
*********** Begin Internal Register Settle Subroutine ***********
SETTLE pshx
ldx #$0FFF
DEC dex
bne DEC
pulx
rts
*********** End Internal Register Settle Subroutine ***********
*********** Begin One Second Delay Subroutine ***********
ONESEC psha
pshb
pshx
pshy
ldy #$0001 ;IY <--- 1 (second)
L3 ldx #2811T ;X <--- 2811d
L2 ldab #141T ;ACCB <--- 141 (1 second delay loop input var)
L1 decb
bne L1
dex
bne L2
dey
bne L3
puly
pulx
pulb
pula
rts
*********** End One Second Delay Subroutine ***********
org $FFF6
fdb START,START,START,START,START
|