1 |
74 |
ja_rd |
0001 0000 ;*******************************************************************************
|
2 |
|
|
0002 0000 ; tb1.asm -- light8080 core test bench 1: interrupt & halt test
|
3 |
|
|
0003 0000 ;*******************************************************************************
|
4 |
|
|
0004 0000 ; Should be used with test bench template vhdl\test\tb_template.vhdl
|
5 |
|
|
0005 0000 ; Assembler format compatible with TASM for DOS and Linux.
|
6 |
|
|
0006 0000 ;*******************************************************************************
|
7 |
|
|
0007 0000 ; This program will test a few different interrupt vectors and the interrupt
|
8 |
|
|
0008 0000 ; enable/disable flag, but not exhaustively.
|
9 |
|
|
0009 0000 ; Besides, it will not test long intr assertions (more than 1 cycle).
|
10 |
|
|
0010 0000 ;*******************************************************************************
|
11 |
|
|
0011 0000
|
12 |
|
|
0012 0000 ; DS pseudo-directive; reserve space in bytes, without initializing it
|
13 |
|
|
0013 0000 #define ds(n) \.org $+n
|
14 |
|
|
0014 0000
|
15 |
|
|
0015 0000 ; OUTing some value here will trigger intr in the n-th cycle from the end of
|
16 |
|
|
0016 0000 ; the 'out' instruction. For example, writing a 0 will trigger intr in the 1st
|
17 |
|
|
0017 0000 ; cycle of the following instruction, and so on.
|
18 |
|
|
0018 0000 intr_trigger: .equ 11h
|
19 |
|
|
0019 0000 ; The value OUTput to this address will be used as the 'interrupt source' when
|
20 |
|
|
0020 0000 ; the intr line is asserted. In the inta acknowledge cycle, the simulated
|
21 |
|
|
0021 0000 ; interrupt logic will feed the CPU the instruction at memory address
|
22 |
|
|
0022 0000 ; 40h+source*4. See vhdl\test\tb_template.vhdl for details.
|
23 |
|
|
0023 0000 intr_source: .equ 10h
|
24 |
|
|
0024 0000 ; The value OUTput to this port is the number of cycles the intr signal will
|
25 |
|
|
0025 0000 ; remain high after being asserted. By default this is 1 cycle.
|
26 |
|
|
0026 0000 intr_width: .equ 12h
|
27 |
|
|
0027 0000 ; OUTing something here will stop the simulation. A 0x055 will signal a
|
28 |
|
|
0028 0000 ; success, a 0x0aa a failure.
|
29 |
|
|
0029 0000 test_outcome: .equ 20h
|
30 |
|
|
0030 0000
|
31 |
|
|
0031 0000 ;*******************************************************************************
|
32 |
|
|
0032 0000
|
33 |
|
|
0033 0000 .org 0H
|
34 |
|
|
0034 0000 C3 60 00 jmp start ; skip the rst address area
|
35 |
|
|
0035 0003
|
36 |
|
|
0036 0003 ; used to test that RST works
|
37 |
|
|
0037 0020 .org 20H
|
38 |
|
|
0038 0020 C6 01 adi 1H
|
39 |
|
|
0039 0022 FB ei
|
40 |
|
|
0040 0023 C9 ret
|
41 |
|
|
0041 0024
|
42 |
|
|
0042 0024 ; used to test the RST instruction as intr vector
|
43 |
|
|
0043 0028 .org 28H
|
44 |
|
|
0044 0028 3C inr a
|
45 |
|
|
0045 0029 FB ei
|
46 |
|
|
0046 002A C9 ret
|
47 |
|
|
0047 002B
|
48 |
|
|
0048 002B ;***** simulated interrupt vectors in area 0040h-005fh *****************
|
49 |
|
|
0049 002B
|
50 |
|
|
0050 0040 .org 40h+(0*4) ; simulated interrupt vector 0
|
51 |
|
|
0051 0040 3C inr a
|
52 |
|
|
0052 0044 .org 40h+(1*4) ; simulated interrupt vector 1
|
53 |
|
|
0053 0044 EF rst 5
|
54 |
|
|
0054 0048 .org 40h+(2*4) ; simulated interrupt vector 2
|
55 |
|
|
0055 0048 23 inx h
|
56 |
|
|
0056 004C .org 40h+(3*4) ; simulated interrupt vector 3
|
57 |
|
|
0057 004C 3E 42 mvi a,42h
|
58 |
|
|
0058 0050 .org 40h+(4*4) ; simulated interrupt vector 4
|
59 |
|
|
0059 0050 21 34 12 lxi h,1234h
|
60 |
|
|
0060 0054 .org 40h+(5*4) ; simulated interrupt vector 5
|
61 |
|
|
0061 0054 C3 2F 01 jmp test_jump
|
62 |
|
|
0062 0058 .org 40h+(6*4) ; simulated interrupt vector 6
|
63 |
|
|
0063 0058 CD 34 01 call test_call
|
64 |
|
|
0064 005C .org 40h+(7*4) ; simulated interrupt vector 7
|
65 |
|
|
0065 005C CD 37 01 call shouldnt_trigger
|
66 |
|
|
0066 005F
|
67 |
|
|
0067 005F
|
68 |
|
|
0068 005F ;***** program entry point *********************************************
|
69 |
|
|
0069 005F
|
70 |
|
|
0070 0060 start: .org 60H
|
71 |
|
|
0071 0060 31 7A 01 lxi sp,stack
|
72 |
|
|
0072 0063
|
73 |
|
|
0073 0063 ; first of all, make sure the RST instruction works, we have a valid
|
74 |
|
|
0074 0063 ; simulated stack, etc.
|
75 |
|
|
0075 0063 3E 13 mvi a,13h
|
76 |
|
|
0076 0065 E7 rst 4 ; this should add 1 to ACC
|
77 |
|
|
0077 0066 FE 14 cpi 14h
|
78 |
|
|
0078 0068 C2 2A 01 jnz fail
|
79 |
|
|
0079 006B
|
80 |
|
|
0080 006B ; now we'll try a few different interrupt vectors (single byte and
|
81 |
|
|
0081 006B ; multi-byte). Since interrupts are disabled upon acknowledge, we have
|
82 |
|
|
0082 006B ; to reenable them after every test.
|
83 |
|
|
0083 006B
|
84 |
|
|
0084 006B ; try single-byte interrupt vector: INR A
|
85 |
|
|
0085 006B 3E 00 mvi a,0
|
86 |
|
|
0086 006D D3 10 out intr_source
|
87 |
|
|
0087 006F FB ei
|
88 |
|
|
0088 0070 3E 14 mvi a,014h
|
89 |
|
|
0089 0072 D3 11 out intr_trigger
|
90 |
|
|
0090 0074 3E 27 mvi a,027h
|
91 |
|
|
0091 0076 00 nop ; the interrupt will hit in this nop area
|
92 |
|
|
0092 0077 00 nop
|
93 |
|
|
0093 0078 00 nop
|
94 |
|
|
0094 0079 00 nop
|
95 |
|
|
0095 007A FE 28 cpi 028h
|
96 |
|
|
0096 007C C2 2A 01 jnz fail
|
97 |
|
|
0097 007F
|
98 |
|
|
0098 007F ; another single-byte vector: RST 5
|
99 |
|
|
0099 007F 3E 01 mvi a,1
|
100 |
|
|
0100 0081 D3 10 out intr_source
|
101 |
|
|
0101 0083 FB ei
|
102 |
|
|
0102 0084 3E 14 mvi a,014h
|
103 |
|
|
0103 0086 D3 11 out intr_trigger ; the interrupt vector will do a rst 5, and
|
104 |
|
|
0104 0088 3E 20 mvi a,020h ; the rst routine will add 1 to the ACC
|
105 |
|
|
0105 008A 00 nop ; and reenable interrupts
|
106 |
|
|
0106 008B 00 nop
|
107 |
|
|
0107 008C 00 nop
|
108 |
|
|
0108 008D 00 nop
|
109 |
|
|
0109 008E FE 21 cpi 021h
|
110 |
|
|
0110 0090 C2 2A 01 jnz fail
|
111 |
|
|
0111 0093
|
112 |
|
|
0112 0093 ; another single-byte code: INX H
|
113 |
|
|
0113 0093 21 FF 13 lxi h,13ffh
|
114 |
|
|
0114 0096 3E 02 mvi a,2
|
115 |
|
|
0115 0098 D3 10 out intr_source
|
116 |
|
|
0116 009A FB ei
|
117 |
|
|
0117 009B 3E 04 mvi a,4
|
118 |
|
|
0118 009D D3 11 out intr_trigger
|
119 |
|
|
0119 009F 00 nop
|
120 |
|
|
0120 00A0 00 nop
|
121 |
|
|
0121 00A1 7D mov a,l
|
122 |
|
|
0122 00A2 FE 00 cpi 0H
|
123 |
|
|
0123 00A4 C2 2A 01 jnz fail
|
124 |
|
|
0124 00A7 7C mov a,h
|
125 |
|
|
0125 00A8 FE 14 cpi 14h
|
126 |
|
|
0126 00AA C2 2A 01 jnz fail
|
127 |
|
|
0127 00AD
|
128 |
|
|
0128 00AD ; a two-byte instruction: mvi a, 42h
|
129 |
|
|
0129 00AD 3E 03 mvi a,3
|
130 |
|
|
0130 00AF D3 10 out intr_source
|
131 |
|
|
0131 00B1 FB ei
|
132 |
|
|
0132 00B2 3E 04 mvi a,4
|
133 |
|
|
0133 00B4 D3 11 out intr_trigger
|
134 |
|
|
0134 00B6 00 nop
|
135 |
|
|
0135 00B7 00 nop
|
136 |
|
|
0136 00B8 FE 42 cpi 42h
|
137 |
|
|
0137 00BA C2 2A 01 jnz fail
|
138 |
|
|
0138 00BD
|
139 |
|
|
0139 00BD ; a three-byte instruction: lxi h,1234h
|
140 |
|
|
0140 00BD 3E 04 mvi a,4
|
141 |
|
|
0141 00BF D3 10 out intr_source
|
142 |
|
|
0142 00C1 FB ei
|
143 |
|
|
0143 00C2 3E 04 mvi a,4
|
144 |
|
|
0144 00C4 D3 11 out intr_trigger
|
145 |
|
|
0145 00C6 00 nop
|
146 |
|
|
0146 00C7 00 nop
|
147 |
|
|
0147 00C8 7C mov a,h
|
148 |
|
|
0148 00C9 FE 12 cpi 12h
|
149 |
|
|
0149 00CB C2 2A 01 jnz fail
|
150 |
|
|
0150 00CE 7D mov a,l
|
151 |
|
|
0151 00CF FE 34 cpi 34h
|
152 |
|
|
0152 00D1 C2 2A 01 jnz fail
|
153 |
|
|
0153 00D4
|
154 |
|
|
0154 00D4 ; a 3-byte jump: jmp test_jump
|
155 |
|
|
0155 00D4 ; if this fails, the test will probably derail
|
156 |
|
|
0156 00D4 3E 05 mvi a,5
|
157 |
|
|
0157 00D6 D3 10 out intr_source
|
158 |
|
|
0158 00D8 FB ei
|
159 |
|
|
0159 00D9 3E 04 mvi a,4
|
160 |
|
|
0160 00DB D3 11 out intr_trigger
|
161 |
|
|
0161 00DD 00 nop
|
162 |
|
|
0162 00DE 00 nop
|
163 |
|
|
0163 00DF comeback:
|
164 |
|
|
0164 00DF FE 79 cpi 79h
|
165 |
|
|
0165 00E1 C2 2A 01 jnz fail
|
166 |
|
|
0166 00E4
|
167 |
|
|
0167 00E4 ; a 3-byte call: call test_call
|
168 |
|
|
0168 00E4 ; if this fails, the test will probably derail
|
169 |
|
|
0169 00E4 3E 06 mvi a,6
|
170 |
|
|
0170 00E6 D3 10 out intr_source
|
171 |
|
|
0171 00E8 FB ei
|
172 |
|
|
0172 00E9 3E 04 mvi a,4
|
173 |
|
|
0173 00EB D3 11 out intr_trigger
|
174 |
|
|
0174 00ED 3C inr a
|
175 |
|
|
0175 00EE ; the interrupt will come back here, hopefully
|
176 |
|
|
0176 00EE 00 nop
|
177 |
|
|
0177 00EF FE 05 cpi 05h
|
178 |
|
|
0178 00F1 C2 2A 01 jnz fail
|
179 |
|
|
0179 00F4 78 mov a,b
|
180 |
|
|
0180 00F5 FE 19 cpi 19h
|
181 |
|
|
0181 00F7 C2 2A 01 jnz fail
|
182 |
|
|
0182 00FA
|
183 |
|
|
0183 00FA ; now, with interrupts disabled, make sure interrupts are ignored
|
184 |
|
|
0184 00FA F3 di
|
185 |
|
|
0185 00FB 3E 07 mvi a,07h ; source 7 catches any unwanted interrupts
|
186 |
|
|
0186 00FD D3 10 out intr_source
|
187 |
|
|
0187 00FF 3E 04 mvi a,04h
|
188 |
|
|
0188 0101 D3 11 out intr_trigger
|
189 |
|
|
0189 0103 00 nop
|
190 |
|
|
0190 0104 00 nop
|
191 |
|
|
0191 0105 00 nop
|
192 |
|
|
0192 0106
|
193 |
|
|
0193 0106 ; Ok. So far we have tested only 1-cycle intr assertions. Now we'll
|
194 |
|
|
0194 0106 ; see what happens when we leave intr asserted for a long time (as would
|
195 |
|
|
0195 0106 ; happen intr was used for single-step debugging, for instance)
|
196 |
|
|
0196 0106
|
197 |
|
|
0197 0106 ; try single-byte interrupt vector (INR A)
|
198 |
|
|
0198 0106 3E 50 mvi a, 80
|
199 |
|
|
0199 0108 D3 12 out intr_width
|
200 |
|
|
0200 010A 3E 01 mvi a,1
|
201 |
|
|
0201 010C D3 10 out intr_source
|
202 |
|
|
0202 010E FB ei
|
203 |
|
|
0203 010F 3E 14 mvi a,014h
|
204 |
|
|
0204 0111 D3 11 out intr_trigger
|
205 |
|
|
0205 0113 3E 27 mvi a,027h
|
206 |
|
|
0206 0115 00 nop ; the interrupts will hit in this nop area
|
207 |
|
|
0207 0116 00 nop
|
208 |
|
|
0208 0117 3C inr a
|
209 |
|
|
0209 0118 00 nop
|
210 |
|
|
0210 0119 00 nop
|
211 |
|
|
0211 011A 3C inr a
|
212 |
|
|
0212 011B 00 nop
|
213 |
|
|
0213 011C 00 nop
|
214 |
|
|
0214 011D 00 nop
|
215 |
|
|
0215 011E 00 nop
|
216 |
|
|
0216 011F 00 nop
|
217 |
|
|
0217 0120 FE 2B cpi 02bh
|
218 |
|
|
0218 0122 C2 2A 01 jnz fail
|
219 |
|
|
0219 0125
|
220 |
|
|
0220 0125
|
221 |
|
|
0221 0125 ; finished, run into the success outcome code
|
222 |
|
|
0222 0125
|
223 |
|
|
0223 0125 success:
|
224 |
|
|
0224 0125 3E 55 mvi a,55h
|
225 |
|
|
0225 0127 D3 20 out test_outcome
|
226 |
|
|
0226 0129 76 hlt
|
227 |
|
|
0227 012A 3E AA fail: mvi a,0aah
|
228 |
|
|
0228 012C D3 20 out test_outcome
|
229 |
|
|
0229 012E 76 hlt
|
230 |
|
|
0230 012F
|
231 |
|
|
0231 012F test_jump:
|
232 |
|
|
0232 012F 3E 79 mvi a,79h
|
233 |
|
|
0233 0131 C3 DF 00 jmp comeback
|
234 |
|
|
0234 0134
|
235 |
|
|
0235 0134 test_call:
|
236 |
|
|
0236 0134 06 19 mvi b,19h
|
237 |
|
|
0237 0136 C9 ret
|
238 |
|
|
0238 0137
|
239 |
|
|
0239 0137 ; called when an interrupt has been acknowledged that shouldn't have
|
240 |
|
|
0240 0137 shouldnt_trigger:
|
241 |
|
|
0241 0137 C3 2A 01 jmp fail
|
242 |
|
|
0242 013A
|
243 |
|
|
0243 013A ; data space
|
244 |
|
|
0244 013A ds(64)
|
245 |
|
|
0244 017A
|
246 |
|
|
0245 017A stack: ds(2)
|
247 |
|
|
0245 017C
|
248 |
|
|
0246 017C .end
|
249 |
|
|
0247 017C tasm: Number of errors = 0
|