-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_djnz.spin
71 lines (48 loc) · 1.06 KB
/
test_djnz.spin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
dat
orgh 0
org 0
andn outb, ##$FFFF
or dirb, ##$FFFF
call #test1 ' Normal decrement from non-zero start
call #test2 ' Decrement starting at zero
.end jmp #.end
'-------------------------------------------------------------------------------
test1 setcz #%10 wc, wz
mov d, #10
mov c, #0
.loop add c, #1
djnz d, #.loop ' TEST INSTRUCTION
setbc cz, #1
setbz cz, #0
cmp d, #0 wz
if_nz jmp #.end
cmp c, #10 wz
if_nz jmp #.end
cmp cz, #%10 wz
if_nz jmp #.end
setb outb, #0
.end ret
'-------------------------------------------------------------------------------
test2 setcz #%01 wc, wz
mov d, #0
mov c, #11
.loop sub c, #1
tjz c, #.continue ' exit loop after C goes to zero
djnz d, #.loop ' TEST INSTRUCTION
.continue setbc cz, #1
setbz cz, #0
cmp d, ##-10 wz
if_nz jmp #.end
cmp c, #0 wz
if_nz jmp #.end
cmp cz, #%01 wz
if_nz jmp #.end
setb outb, #1
.end ret
'-------------------------------------------------------------------------------
d res 1
c res 1
cz res 1
r res 1
rc res 1
rcz res 1