-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.asm
336 lines (292 loc) · 10.2 KB
/
test.asm
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
;; ____________________________
;; ██▀▀█▀▀██▀▀▀▀▀▀▀█▀▀█ │ ▄▄▄ ▄▄
;; ██ ▀ █▄ ▀██▄ ▀ ▄█ ▄▀▀ █ │ ▀█▄ ▄▀██ ▄█▄█ ██▀▄ ██ ▄███
;; █ █ █ ▀▀ ▄█ █ █ ▀▄█ █▄ │ ▄▄█▀ ▀▄██ ██ █ ██▀ ▀█▄ ▀█▄▄
;; ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀────────┘ ▀▀
;; VRAM access timing sample
;;─────────────────────────────────────────────────────────────────────────────
.module test
;;=============================================================================
;; DEFINES
;;=============================================================================
TEST_COUNT = 256
P_VDP_0 = 0x98
P_VDP_DATA = P_VDP_0
P_VDP_1 = 0x99
P_VDP_REG = P_VDP_1
P_VDP_ADDR = P_VDP_1
P_VDP_STAT = P_VDP_1
F_VDP_REG = 0x80 ;; VDP register write port (bit 7=1 in second write)
F_VDP_VRAM = 0x00 ;; VRAM address register (bit 7=0 in second write)
F_VDP_WRIT = 0x40 ;; bit 6: read/write access (1=write)
F_VDP_READ = 0x00 ;; bit 6: read/write access (0=read)
RAM_BUFFER = 0xD000
;;=============================================================================
;; FUNCTIONS
;;=============================================================================
;;-----------------------------------------------------------------------------
;; Set VRAM address to write in
;; void SetWriteVRAM(u16 dest -> HL)
;;-----------------------------------------------------------------------------
_SetWriteVRAM::
;; Setup destination address (LSB)
ld a, l
out (P_VDP_ADDR), a ;; RegPort = (dest & 0x00FF);
;; Setup destination address (MSB)
ld a, h
and a, #0x3F ;; reset 2 MSB bits
or a, #F_VDP_WRIT ;; add write flag
out (P_VDP_ADDR), a ;; RegPort = ((dest >> 8) & 0x3F) + F_VDP_WRIT;
ret
;;-----------------------------------------------------------------------------
;; Set VRAM address to write in
;; void SetReadVRAM(u16 dest -> HL)
;;-----------------------------------------------------------------------------
_SetReadVRAM::
;; Setup destination address (LSB)
ld a, l
out (P_VDP_ADDR), a ;; RegPort = (dest & 0x00FF);
;; Setup destination address (MSB)
ld a, h
and a, #0x3F ;; reset 2 MSB bits
; or a, #F_VDP_READ ;; add read flag
out (P_VDP_ADDR), a ;; RegPort = ((dest >> 8) & 0x3F) + F_VDP_WRIT;
ret
;;-----------------------------------------------------------------------------
;; Create buffer in RAM filled with register A's value
CreateBuffer:
ld hl, #RAM_BUFFER
ld de, #RAM_BUFFER+1
ld (hl), a
ld bc, #TEST_COUNT-1
ldir
ret
;;-----------------------------------------------------------------------------
;; test VRAM - 12 T-States - out(n),a
;; void test_12(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_12::
.rept TEST_COUNT
out (P_VDP_DATA), a ;; 12 ts | 2 B
.endm
ret
_Test_12_length::
.dw _Test_12_length - _Test_12
;;-----------------------------------------------------------------------------
;; test VRAM - 14 T-States - out(c),a
;; void test_14(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_14::
ld c, #P_VDP_DATA
.rept TEST_COUNT
out (c), a ;; 14 ts | 2 B
.endm
ret
_Test_14_length::
.dw _Test_14_length - _Test_14
;;-----------------------------------------------------------------------------
;; test VRAM - 17 T-States - out(n),a; nop
;; void test_17(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_17::
.rept TEST_COUNT
out (P_VDP_DATA), a ;; 12 ts | 2 B
nop ;; 5 ts | 1 B
.endm
ret
_Test_17_length::
.dw _Test_17_length - _Test_17
;;-----------------------------------------------------------------------------
;; test VRAM - 18 T-States - outi
;; void test_18(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_18::
;; Create buffer in RAM
call CreateBuffer
;; Copy to VRAM
ld hl, #RAM_BUFFER
ld c, #P_VDP_DATA
.rept TEST_COUNT
outi ;; 18 ts | 2 B
.endm
ret
_Test_18_length::
.dw _Test_18_length - _Test_18
;;-----------------------------------------------------------------------------
;; test VRAM - 19 T-States - out (c),a; nop
;; void test_19(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_19::
ld c, #P_VDP_DATA
.rept TEST_COUNT
out (c), a ;; 14 ts | 2 B
nop ;; 5 ts | 1 B
.endm
ret
_Test_19_length::
.dw _Test_19_length - _Test_19
;;-----------------------------------------------------------------------------
;; test VRAM - 20 T-States - out (n),a; cp (hl)
;; void test_20(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_20::
.rept TEST_COUNT
out (P_VDP_DATA), a ;; 12 ts | 2 B
cp (hl) ;; 8 ts | 1 B
.endm
ret
_Test_20_length::
.dw _Test_20_length - _Test_20
;;-----------------------------------------------------------------------------
;; test VRAM - 21 T-States - out (c),a; inc de
;; void test_21(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_21::
ld c, #P_VDP_DATA
.rept TEST_COUNT
out (c), a ;; 14 ts | 2 B
inc de ;; 7 ts | 1 B
.endm
ret
_Test_21_length::
.dw _Test_21_length - _Test_21
;;-----------------------------------------------------------------------------
;; test VRAM - 22 T-States - out (c),a; cp (hl)
;; void test_22(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_22::
ld c, #P_VDP_DATA
.rept TEST_COUNT
out (c), a ;; 14 ts | 2 B
cp (hl) ;; 8 ts | 1 B
.endm
ret
_Test_22_length::
.dw _Test_22_length - _Test_22
;;-----------------------------------------------------------------------------
;; test VRAM - 23 T-States - otir
;; void test_23(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_23::
;; Create buffer in RAM
call CreateBuffer
;; Copy to VRAM
ld hl, #RAM_BUFFER
ld b, #TEST_COUNT
ld c, #P_VDP_DATA
otir ;; 23 ts | 2 B
ret
_Test_23_length::
.dw _Test_23_length - _Test_23
;;-----------------------------------------------------------------------------
;; test VRAM - 24 T-States - out (n),a; inc (hl)
;; void test_24(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_24::
ld hl, #RAM_BUFFER
.rept TEST_COUNT
out (P_VDP_DATA), a ;; 12 ts | 2 B
inc (hl) ;; 12 ts | 1 B
.endm
ret
_Test_24_length::
.dw _Test_24_length - _Test_24
;;-----------------------------------------------------------------------------
;; test VRAM - 25 T-States - outi; inc de
;; void test_25(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_25::
;; Create buffer in RAM
call CreateBuffer
;; Copy to VRAM
ld hl, #RAM_BUFFER
ld c, #P_VDP_DATA
.rept TEST_COUNT
outi ;; 18 ts | 2 B
inc de ;; 7 ts | 1 B
.endm
ret
_Test_25_length::
.dw _Test_25_length - _Test_25
;;-----------------------------------------------------------------------------
;; test VRAM - 26 T-States - out (n),a; djnz
;; void test_26(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_26::
ld b, #TEST_COUNT
test26:
out (P_VDP_DATA), a ;; 12 ts | 2 B
djnz test26 ;; 14 ts
ret
_Test_26_length::
.dw _Test_26_length - _Test_26
;;-----------------------------------------------------------------------------
;; test VRAM - 27 T-States - out (n),a; cp (hl); inc de
;; void test_27(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_27::
.rept TEST_COUNT
out (P_VDP_DATA), a ;; 12 ts | 2 B
cp (hl) ;; 8 ts | 1 B
inc de ;; 7 ts | 1 B
.endm
ret
_Test_27_length::
.dw _Test_27_length - _Test_27
;;-----------------------------------------------------------------------------
;; test VRAM - 28 T-States - out (n),a; cp (hl) x 2
;; void test_28(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_28::
.rept TEST_COUNT
out (P_VDP_DATA), a ;; 12 ts | 2 B
cp (hl) ;; 8 ts | 1 B
cp (hl) ;; 8 ts | 1 B
.endm
ret
_Test_28_length::
.dw _Test_28_length - _Test_28
;;-----------------------------------------------------------------------------
;; test VRAM - 29 T-States - outi; ld i,a
;; void test_29(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_29::
;; Create buffer in RAM
call CreateBuffer
;; Copy to VRAM
ld hl, #RAM_BUFFER
ld c, #P_VDP_DATA
.rept TEST_COUNT
outi ;; 18 ts | 2 B
ld i, a ;; 11 ts | 2 B
.endm
ret
_Test_29_length::
.dw _Test_29_length - _Test_29
;;-----------------------------------------------------------------------------
;; test VRAM - 30 T-States - out (c),a; cp (hl) x 2
;; void test_30(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_30::
ld c, #P_VDP_DATA
.rept TEST_COUNT
out (c), a ;; 14 ts | 2 B
cp (hl) ;; 8 ts | 1 B
cp (hl) ;; 8 ts | 1 B
.endm
ret
_Test_30_length::
.dw _Test_30_length - _Test_30
;;-----------------------------------------------------------------------------
;; test VRAM - 31 T-States - out(n),a; nop; djnz
;; void test_31(u8 value -> A)
;;-----------------------------------------------------------------------------
_Test_31::
ld b, #TEST_COUNT
test31:
out (P_VDP_DATA), a ;; 12 ts | 2 B
nop ;; 5 ts | 1 B
djnz test31 ;; 14 ts
ret
_Test_31_length::
.dw _Test_31_length - _Test_31