-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_djns.spin
95 lines (64 loc) · 1.38 KB
/
test_djns.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
call #test3 ' Decrement starting from -1
.end jmp #.end
'-------------------------------------------------------------------------------
test1 setcz #%01 wc, wz
mov d, #10
mov c, #0
.loop add c, #1
djns d, #.loop ' TEST INSTRUCTION
setbc cz, #1
setbz cz, #0
cmp d, ##-1 wz
if_nz jmp #.end
cmp c, #11 wz
if_nz jmp #.end
cmp cz, #%01 wz
if_nz jmp #.end
setb outb, #0
.end ret
'-------------------------------------------------------------------------------
test2 setcz #%01 wc, wz
mov d, #0
mov c, #0
.loop add c, #1
djns d, #.loop ' TEST INSTRUCTION
setbc cz, #1
setbz cz, #0
cmp d, ##-1 wz
if_nz jmp #.end
cmp c, #1 wz
if_nz jmp #.end
cmp cz, #%01 wz
if_nz jmp #.end
setb outb, #1
.end ret
'-------------------------------------------------------------------------------
test3 setcz #%01 wc, wz
mov d, ##-1
mov c, #0
.loop add c, #1
djns d, #.loop ' TEST INSTRUCTION
setbc cz, #1
setbz cz, #0
cmp d, ##-2 wz
if_nz jmp #.end
cmp c, #1 wz
if_nz jmp #.end
cmp cz, #%01 wz
if_nz jmp #.end
setb outb, #2
.end ret
'-------------------------------------------------------------------------------
d res 1
c res 1
cz res 1
r res 1
rc res 1
rcz res 1