2 * Copyright (C) 1996-1998 Szeredi Miklos
3 * Email: mszeredi@inf.bme.hu
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. See the file COPYING.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 byte z80c_incf_tbl
[256];
24 byte z80c_decf_tbl
[256];
25 byte z80c_addf_tbl
[256];
26 byte z80c_subf_tbl
[256];
27 byte z80c_orf_tbl
[256];
30 void PRNM(pushpc
)(void)
43 static int parity(int b
)
49 for(i
= 8; i
; i
--) par
^= (b
& 1), b
>>= 1;
53 void PRNM(local_init
)(void)
62 for(i
= 0; i
< 0x100; i
++) {
63 z80c_incf_tbl
[i
] = z80c_decf_tbl
[i
] = z80c_orf_tbl
[i
] = 0;
65 z80c_orf_tbl
[i
] |= i
& (SF
| B3F
| B5F
);
66 z80c_incf_tbl
[i
] |= i
& (SF
| B3F
| B5F
);
67 z80c_decf_tbl
[i
] |= i
& (SF
| B3F
| B5F
);
69 if(!parity(i
)) z80c_orf_tbl
[i
] |= PVF
;
72 z80c_incf_tbl
[0] |= ZF
;
73 z80c_decf_tbl
[0] |= ZF
;
74 z80c_orf_tbl
[0] |= ZF
;
76 z80c_incf_tbl
[0x80] |= PVF
;
77 z80c_decf_tbl
[0x7F] |= PVF
;
79 for(i
= 0; i
< 0x100; i
++) {
96 z80c_addf_tbl
[i
] |= SF
;
97 z80c_subf_tbl
[i
] |= SF
;
100 z80c_addf_tbl
[i
] |= B5F
;
101 z80c_subf_tbl
[i
] |= B5F
;
104 z80c_addf_tbl
[i
] |= B3F
;
105 z80c_subf_tbl
[i
] |= B3F
;
108 if((c1
&& c2
) || (!cr
&& (c1
|| c2
))) z80c_addf_tbl
[i
] |= CF
;
109 if((h1
&& h2
) || (!hr
&& (h1
|| h2
))) z80c_addf_tbl
[i
] |= HF
;
111 if((!c1
&& !c2
&& cr
) || (c1
&& c2
&& !cr
)) z80c_addf_tbl
[i
] |= PVF
;
114 if((c2
&& cr
) || (!c1
&& (c2
|| cr
))) z80c_subf_tbl
[i
] |= CF
;
115 if((h2
&& hr
) || (!h1
&& (h2
|| hr
))) z80c_subf_tbl
[i
] |= HF
;
117 if((!c2
&& !cr
&& c1
) || (c2
&& cr
&& !c1
)) z80c_subf_tbl
[i
] |= PVF
;
120 z80c_subf_tbl
[i
] |= NF
;
125 TAB(incf_tbl
) = z80c_incf_tbl
;
126 TAB(decf_tbl
) = z80c_decf_tbl
;
127 TAB(addf_tbl
) = z80c_addf_tbl
;
128 TAB(subf_tbl
) = z80c_subf_tbl
;
129 TAB(orf_tbl
) = z80c_orf_tbl
;
131 PORT(inports
) = PRNM(inports
);
132 PORT(outports
) = PRNM(outports
);
134 SPECP(fe_inport_high
) = SPNM(fe_inport_high
);
140 int PRNM(step
)(int tc
)
148 DANM(rl7
) = RR
& 0x80;
150 if(DANM(haltstate
)) {
152 nn
= (DANM(tc
) - 1) / 4 + 1;
167 z80p
= (*z80c_op_tab
[nextop
])(z80p
);
169 (*z80c_op_tab
[nextop
])();
172 } while(DANM(tc
) > 0);
174 RR
= (RR
& 0x7F) | DANM(rl7
);