# HG changeset patch # User Michael Pavone # Date 1549352795 28800 # Node ID 6290c88949bd0bf41336005d1094bfe34d080db4 # Parent 3dbfb4524ad27a02d5c45bb46902bf4678a557a5 Fixed CPI/CPD/CPIR/CPDR in new Z80 core diff -r 3dbfb4524ad2 -r 6290c88949bd cpu_dsl.py --- a/cpu_dsl.py Mon Feb 04 22:51:56 2019 -0800 +++ b/cpu_dsl.py Mon Feb 04 23:46:35 2019 -0800 @@ -418,7 +418,7 @@ raise Exception('Unknown flag calc type: ' + calc) if prog.carryFlowDst: if prog.lastOp.op != 'cmp': - output.append('\n\t{dst} = {tmpdst};'.format(dst = prog.resolveParam(prog.lastDst, None, {}), tmpdst = prog.carryFlowDst)) + output.append('\n\t{dst} = {tmpdst};'.format(dst = prog.resolveParam(prog.lastDst, prog.currentScope, {}), tmpdst = prog.carryFlowDst)) prog.carryFlowDst = None if parity: if paritySize > 8: @@ -1363,8 +1363,8 @@ def getTemp(self, size): if size in self.temp: return ('', self.temp[size]) - self.temp[size] = 'tmp{sz}'.format(sz=size); - return ('\n\tuint{sz}_t tmp{sz};'.format(sz=size), self.temp[size]) + self.temp[size] = 'gen_tmp{sz}__'.format(sz=size); + return ('\n\tuint{sz}_t gen_tmp{sz}__;'.format(sz=size), self.temp[size]) def resolveParam(self, param, parent, fieldVals, allowConstant=True, isdst=False): keepGoing = True diff -r 3dbfb4524ad2 -r 6290c88949bd z80.cpu --- a/z80.cpu Mon Feb 04 22:51:56 2019 -0800 +++ b/z80.cpu Mon Feb 04 23:46:35 2019 -0800 @@ -2127,11 +2127,18 @@ z80_cpd_cpi local tmp 16 local tmp8 8 + local hf 8 arg change 16 z80_fetch_mod_hl change sub scratch1 a tmp8 - update_flags SZHXN1 + update_flags SZHN1 + + lsr chflags 3 hf + and 1 hf hf + + sub hf tmp8 tmp8 + update_flags X and 0x2 tmp8 tmp8 lsl tmp8 4 tmp8 @@ -2159,21 +2166,31 @@ z80_cpd_cpi 1 if pvflag + if zflag + + else + add 1 pc wz sub 2 pc pc cycles 5 end + end ed 10111001 cpdr z80_cpd_cpi -1 if pvflag + if zflag + + else + add 1 pc wz sub 2 pc pc cycles 5 end + end 00100111 daa local diff 8