Skip to content

Commit 24f31f2

Browse files
committed
minor code cleanup in z80_gen.py
1 parent 51c9ef1 commit 24f31f2

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

codegen/z80_gen.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ def __init__(self, name, cond, flags):
2323
self.prefix = ''
2424
self.multiple = False
2525
self.multiple_first_op_index = -1
26-
self.num_cycles = 0
27-
self.num_steps = 0
2826
self.step_index = -1
2927
self.extra_step_index = -1
3028
self.mcycles = []
@@ -263,13 +261,6 @@ def expand_optable():
263261
op_index += 1; stampout_op('', -1, op_index, find_opdesc('int_im2'))
264262
op_index += 1; stampout_op('', -1, op_index, find_opdesc('nmi'))
265263

266-
# compute number of tcycles in an instruction
267-
def compute_tcycles(op):
268-
cycles = 0
269-
for mcycle in op.mcycles:
270-
cycles += mcycle.tcycles
271-
return cycles
272-
273264
# generate code for one op
274265
def gen_decoder():
275266
indent = 2
@@ -298,40 +289,39 @@ def add(action):
298289
if flag(op, 'redundant'):
299290
next_step = OPS[op.multiple_first_op_index].extra_step_index
300291
action = action.replace("$NEXTSTEP", f'{next_step}')
301-
l(f'case {cur_step:4}: {action}_goto({next_step}); // {op.name} T:{op_step}')
292+
l(f'case {cur_step:4}: {action}_goto({next_step}); // {op.name} ({op_step})')
302293
cur_step += 1
303294
else:
304295
# do not write a payload for redundant ops
305296
if not flag(op, 'redundant'):
306297
next_step = cur_extra_step + 1
307298
action = action.replace("$NEXTSTEP", f'{next_step}')
308-
lx(f'case {cur_extra_step:4}: {action}_goto({next_step}); // {op.name} T:{op_step}')
299+
lx(f'case {cur_extra_step:4}: {action}_goto({next_step}); // {op.name} ({op_step})')
309300
cur_extra_step += 1
310301
op_step += 1
311302

312303
def add_fetch(action):
313304
nonlocal cur_step, cur_extra_step, op_step, op
314305
if op_step == 0 and not flag(op, 'special'):
315-
l(f'case {cur_step:4}: {action}_fetch(); // {op.name} T:{op_step}')
306+
l(f'case {cur_step:4}: {action}_fetch(); // {op.name} ({op_step})')
316307
cur_step += 1
317308
else:
318-
lx(f'case {cur_extra_step:4}: {action}_fetch(); // {op.name} T:{op_step}')
309+
lx(f'case {cur_extra_step:4}: {action}_fetch(); // {op.name} ({op_step})')
319310
cur_extra_step += 1
320311
op_step += 1
321312

322313
def add_stepto(action):
323314
nonlocal cur_step, cur_extra_step, op_step, op
324315
if op_step == 0:
325-
l(f'case {cur_step:4}: {action}goto step_to; // {op.name} T:{op_step}')
316+
l(f'case {cur_step:4}: {action}goto step_to; // {op.name} ({op_step})')
326317
cur_step += 1
327318
else:
328-
lx(f'case {cur_extra_step:4}: {action}goto step_to; // {op.name} T:{op_step}')
319+
lx(f'case {cur_extra_step:4}: {action}goto step_to; // {op.name} ({op_step})')
329320
cur_extra_step += 1
330321
op_step += 1
331322

332323
for op in OPS:
333324
op_step = 0
334-
op.num_cycles = compute_tcycles(op)
335325
op.step_index = cur_step
336326
op.extra_step_index = cur_extra_step
337327

@@ -341,7 +331,7 @@ def add_stepto(action):
341331
pass
342332
elif mcycle.type == 'mread':
343333
addr = mcycle.items['ab']
344-
store = mcycle.items['dst'].replace('_X_', '_gd()')
334+
store = mcycle.items['dst']
345335
add('')
346336
add(f'_wait();_mread({addr});')
347337
add(f'{store}=_gd();{action}')
@@ -357,7 +347,7 @@ def add_stepto(action):
357347
add('')
358348
elif mcycle.type == 'ioread':
359349
addr = mcycle.items['ab']
360-
store = mcycle.items['dst'].replace('_X_', '_gd()')
350+
store = mcycle.items['dst']
361351
add('')
362352
add('')
363353
add(f'_wait();_ioread({addr});')
@@ -390,7 +380,6 @@ def add_stepto(action):
390380
else:
391381
# regular case, jump to the shared fetch block after the
392382
add_fetch(f'{action}')
393-
op.num_steps = op_step
394383
return { 'out_lines': out_lines + out_extra_lines, 'max_step': cur_extra_step }
395384

396385
def extra_step_defines_string(max_step):

0 commit comments

Comments
 (0)