OpenCores
URL https://opencores.org/ocsvn/diogenes/diogenes/trunk

Subversion Repositories diogenes

[/] [diogenes/] [trunk/] [video/] [snake2.asm] - Blame information for rev 238

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 198 fellnhofer
@ l7: stack
2
@ l6: push_function
3
@ l0: return address of leavfuction (push pop im speziell)
4
 
5
  stio l0, [l0]
6
 
7
  LDL l0, :start
8
  LDL l6, :push
9
 
10
  ldi l7, 0x03
11
  jump 
12
  lsi l7, 0xff
13
 
14
 
15
push:
16
  st  h0, [l7]
17
  adi l7, -1
18
  st  h1, [l7]
19
  adi l7, -1
20
  st  h2, [l7]
21
  adi l7, -1
22
  st  h3, [l7]
23
  adi l7, -1
24
  st  h4, [l7]
25
  adi l7, -1
26
  st  h5, [l7]
27
  adi l7, -1
28
  st  h6, [l7]
29
  adi l7, -1
30
  st  h7, [l7]
31
  jump 
32
  adi l7, -1
33
 
34
pop:
35
  adi l7, 1
36
  ld  h7, [l7]
37
  adi l7, 1
38
  ld  h6, [l7]
39
  adi l7, 1
40
  ld  h5, [l7]
41
  adi l7, 1
42
  ld  h4, [l7]
43
  adi l7, 1
44
  ld  h3, [l7]
45
  adi l7, 1
46
  ld  h2, [l7]
47
  adi l7, 1
48
  ld  h1, [l7]
49
  adi l7, 1
50
  ld  h0, [l7]
51
  nop
52
  nop
53
  jump 
54
  nop
55
 
56
 
57
start:
58
 
59
@ initialize snake
60
  ldi   h1, 8
61
l0:
62
  st    h1, [h1]
63
  brnz  h1, :l0
64
  adi   h1, -1
65
 
66
  ldi   h1, 4
67
  ldi   h2, 0
68
 
69
 
70
@ initialize vmem
71
  LDL   h4, :set_tile
72
  ldi   l3, 59     @ max y
73
hloop:
74
  ldi   l2, 79     @ max x
75
pixloop:
76
  call  h0, 

77
  ldi   l1, 0x6b     @ white=0x7f  (black = 6b)
78
 
79
  brnz  l2, :pixloop
80
  adi   l2, -1
81
  brnz  l3, :hloop
82
  adi   l3, -1
83
 
84
  LDL   h3, :delay
85
  LDL   h5, :update
86
loop:
87
  ldi   l0, 0
88
  ldio  l0, [l0]
89
  ldi   l1, 0x01
90
  and   l2, l0, l1     @ select bit for right
91
  sub   h2, h2, l2     @ add bit to direction
92
  shi   l0, -1         @ shift input
93
  and   l2, l0, l1
94
  add   h2, h2, l2     @ add bit to direction
95
  stio  h2, [l0]
96
 
97
  call h0, 
98
 mov  l1, h2
99
 
100
  call  h0, 

@ call delay

101
  ldi   l1, 22         @ 2^20 steps
102
 
103
  brnz  h5, :loop
104
  nop
105
 
106
 
107
update:
108
  call l0, 
109
  nop
110
 
111
 
112
  ldi   l0, 0
113
  ld    l1, [l0]
114
 
115
  @ extract tile,y,x  (l1=tile, l2=x, l3=y)
116
  ldi   l4, 0xff
117
  and   l2, l1, l4
118
  shi   l1, -8
119
  and   l3, l1, l4
120
  ldi   l1, 0x6b
121
 
122
  LDL   l0, :set_tile
123
  call  h0, 
124
  nop
125
 
126
  ldi   l0, 0
127
  ldi   l2, 1
128
 
129
cloop:
130
  ld    l1, [l2]      @ src
131
  adi   l2, 1         @ src + 1
132
  st    l1, [l0]      @ dst
133
  cmpl  l3, l0, h1    @ until dst=highest address)
134
  brnz  l3, :cloop
135
  adi   l0, 1         @ dst + 1
136
 
137
  ldi   l5, 3
138
  and   h2, h2, l5    @ trunc direction
139
 
140
  @ extract tile,y,x  (l1=tile, l2=x, l3=y)
141
  ldi   l4, 0xff
142
  and   l2, l1, l4
143
  shi   l1, -8
144
  and   l3, l1, l4
145
 
146
  shi   l1, -8        @ old direction
147
  shi   l1, 4         @ old direction << 2
148
  or    l1, l1, h2    @  00OO 00NN (old new combination)
149
  adi   l1, 4
150
 
151
  mov   h5, l0
152
  mov   h6, l2
153
  mov   h7, l3
154
 
155
  LDL   l4, :set_tile
156
  call  h0, 
157
  nop
158
  mov   l0, h5
159
  mov   l2, h6
160
  mov   l3, h7
161
 
162
down:
163
  xor   l4, h2, l5
164
  brnz  l4, :up
165
  nop
166
  adi   l3, 1
167
  ldi   l1, 8
168
up:
169
  ldi   l5, 1
170
  xor   l4, h2, l5
171
  brnz  l4, :right
172
  nop
173
  adi   l3, -1
174
  ldi   l1, 9
175
right:
176
  brnz  h2, :left
177
  ldi   l5, 2
178
  adi   l2, 1
179
  ldi   l1, 10
180
left:
181
  xor   l4, h2, l5
182
  brnz  l4, :end_key
183
  nop
184
  adi   l2, -1
185
  ldi   l1, 11
186
end_key:
187
 
188
  mov   l4, h2
189
  shi   l4, 8
190
  or    l4, l4, l3
191
  shi   l4, 8
192
  or    l4, l4, l2
193
  st    l4, [l0]       @ write new head
194
 
195
  LDL   l0, :set_tile
196
  call  h0, 
197
  nop
198
 
199
  ldi   l0, 0
200
  ld    l1, [l0]
201
  @ extract tail tile,y,x  (l1=tile, l2=x, l3=y)
202
  ldi   l4, 0xff
203
  and   l2, l1, l4
204
  shi   l1, -8
205
  and   l3, l1, l4
206
  ldi   l0, 1
207
  ld    l1, [l0]
208
  nop
209
  shi   l1, -16        @ old direction
210
  adi   l1, 0x0c
211
 
212
  LDL   l0, :set_tile
213
  call  h0, 
214
  nop
215
 
216
  adi  h6, l6, 17
217
  jump 
218
  nop
219
 
220
 
221
set_stile:
222
  call l0, 
223
  nop
224
 
225
  ldi  l0, 0xff
226
  and  l2, l1, l0
227
  shi  l1, -8
228
  and  l3, l1, l0
229
 
230
  LDL  h4, :set_tile
231
  call h0, 

232
  shi  l1, -8
233
 
234
  adi  h6, l6, 17
235
  jump 
236
  nop
237
 
238
 
239
set_tile:
240
  call l0, 
241
  nop
242
 
243
  ldi   l4, 0xc0   @ vmem starts at 0xc000
244
  shi   l4, 8
245
 
246
  shi   h3, l3, 7
247
  add   l0, l2, h3
248
  add   l0, l0, l4
249
  stio  l1, [l0]
250
 
251
  adi  h6, l6, 17
252
  jump 
253
  nop
254
 
255
delay:
256
  call l0, 
257
  nop
258
  ldi   l0, 1
259
  sh    l0, l0, l1
260
delay_loop:
261
  brnz   l0, :delay_loop
262
  adi    l0, -1
263
 
264
  adi  h6, l6, 17
265
  jump 
266
  nop
267
 
268
 
269
stop
270
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.