Code:
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
pub main
cognew (@work,0)
repeat
dat
org 0
work movs :loop, #:d 'this gives the address after the main array
nop
djnz :loop, #:loop ' this jumps past the data, it is necessary to start with a djnz so the first cycle is not repeated twice
long 0 ' this fulfills the condition in :loop, and prevents it from doing strange things
long 1,2,3,4,5,6,7,8
:d long 9
:loop cmp a, 0-0 wc, wz
if_b djnz :loop, #:loop ' this works as a jump and post decrement the source register operation
movs b, :loop
add b, #1 ' this corrects for the post decrement of :loop
cmp b, #3 wz, wc 'these two lines verify that it has not stopped due to the zero at the end
if_e jmp #noend
movs :loop2, b
nop
:loop2 mov c, 0-0 ' this retrieves the number from the array
mov b, #1
shl b,c
mov dira, b
mov outa, b
noend jmp #noend ' prevents execution of further data
a long 5
b long 0
c long 0
Bookmarks