Add timer and test program
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
TARGETS=stacktest runram
|
||||
TARGETS=stacktest runram timer
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
@@ -7,6 +7,6 @@ $(TARGETS):
|
||||
xxd -ps $@ | fold -w 2 > $@.hex
|
||||
|
||||
clean:
|
||||
rm $(TARGETS)
|
||||
rm -f $(TARGETS)
|
||||
rm *.hex
|
||||
rm *.list
|
||||
|
||||
38
hw/efinix_fpga/test_programs/timer.s
Normal file
38
hw/efinix_fpga/test_programs/timer.s
Normal file
@@ -0,0 +1,38 @@
|
||||
.code
|
||||
|
||||
LEDS = $efff
|
||||
TIMER_BASE = $eff8
|
||||
TIMER_DIVISOR = 5
|
||||
|
||||
TIMER_OLD = $10
|
||||
|
||||
main:
|
||||
lda #$ff
|
||||
sta TIMER_BASE+TIMER_DIVISOR
|
||||
lda TIMER_BASE
|
||||
sta TIMER_OLD
|
||||
stz LEDS
|
||||
|
||||
|
||||
; load the new value of the timer in a
|
||||
; subtract the old value of the timer
|
||||
; if the result is greater than 30, then do something
|
||||
|
||||
loop:
|
||||
lda TIMER_BASE
|
||||
tax
|
||||
sec
|
||||
sbc TIMER_OLD
|
||||
sec
|
||||
sbc #$20
|
||||
bcc loop
|
||||
|
||||
stx TIMER_OLD
|
||||
inc LEDS
|
||||
bra loop
|
||||
|
||||
.segment "VECTORS"
|
||||
|
||||
.addr main
|
||||
.addr main
|
||||
.addr main
|
||||
Reference in New Issue
Block a user