trunk/src/emu/cpu/arcompact/arcompact_make.py
| r242583 | r242584 | |
| 32 | 32 | flaghandler(f, funcname, opname) |
| 33 | 33 | print >>f, " }" |
| 34 | 34 | |
| 35 | | def EmitGroup04(f,funcname, opname, opexecute, ignore_a, breg_is_dst_only, flagcondition, flaghandler): |
| 35 | def EmitGroup04(f,funcname, opname, opexecute, opwrite, opwrite_alt, ignore_a, breg_is_dst_only, flagcondition, flaghandler): |
| 36 | 36 | # the mode 0x00 handler |
| 37 | 37 | print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p00(OPS_32)" % (funcname) |
| 38 | 38 | print >>f, "{" |
| r242583 | r242584 | |
| 53 | 53 | print >>f, " COMMON32_GET_areg;" |
| 54 | 54 | elif ignore_a == 1: |
| 55 | 55 | print >>f, " //COMMON32_GET_areg; // areg is reserved / not used" |
| 56 | | |
| 56 | elif ignore_a == 2: |
| 57 | print >>f, " //COMMON32_GET_areg; // areg bits already used as opcode select" |
| 58 | |
| 57 | 59 | print >>f, " " |
| 58 | 60 | |
| 59 | 61 | print >>f, " UINT32 c;" |
| r242583 | r242584 | |
| 89 | 91 | print >>f, " /* todo: is the limm, limm syntax valid? (it's pointless.) */" |
| 90 | 92 | print >>f, " /* todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) */" |
| 91 | 93 | print >>f, " %s" % (opexecute) |
| 94 | print >>f, " %s" % (opwrite) |
| 92 | 95 | print >>f, " " |
| 93 | 96 | EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler) |
| 94 | 97 | print >>f, " return m_pc + (size >> 0);" |
| r242583 | r242584 | |
| 116 | 119 | print >>f, " COMMON32_GET_areg;" |
| 117 | 120 | elif ignore_a == 1: |
| 118 | 121 | print >>f, " //COMMON32_GET_areg; // areg is reserved / not used" |
| 122 | elif ignore_a == 2: |
| 123 | print >>f, " //COMMON32_GET_areg; // areg bits already used as opcode select" |
| 119 | 124 | |
| 120 | 125 | print >>f, " " |
| 121 | 126 | |
| r242583 | r242584 | |
| 141 | 146 | print >>f, " " |
| 142 | 147 | print >>f, " /* todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) */" |
| 143 | 148 | print >>f, " %s" % (opexecute) |
| 149 | print >>f, " %s" % (opwrite) |
| 144 | 150 | print >>f, " " |
| 145 | 151 | EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler) |
| 146 | 152 | print >>f, " return m_pc + (size >> 0);" |
| r242583 | r242584 | |
| 149 | 155 | print >>f, "" |
| 150 | 156 | # the mode 0x10 handler |
| 151 | 157 | print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p10(OPS_32)" % (funcname) |
| 152 | | print >>f, "{" |
| 153 | | print >>f, " int size = 4;" |
| 154 | | |
| 155 | | if breg_is_dst_only == 0: |
| 156 | | print >>f, " UINT32 limm = 0;" |
| 158 | if ignore_a == 2: |
| 159 | print >>f, "{" |
| 160 | print >>f, " int size = 4;" |
| 161 | print >>f, " arcompact_fatal(\"illegal arcompact_handle%s_p10 (ares bits already used as opcode select, can't be used as s12) (%s)\\n\");" % (funcname, opname) |
| 162 | print >>f, " return m_pc + (size >> 0);" |
| 163 | print >>f, "}" |
| 164 | else: |
| 165 | print >>f, "{" |
| 166 | print >>f, " int size = 4;" |
| 167 | if breg_is_dst_only == 0: |
| 168 | print >>f, " UINT32 limm = 0;" |
| 169 | |
| 170 | print >>f, "/* int got_limm = 0; */" |
| 171 | print >>f, " " |
| 172 | print >>f, " COMMON32_GET_breg;" |
| 157 | 173 | |
| 158 | | print >>f, "/* int got_limm = 0; */" |
| 159 | | print >>f, " " |
| 160 | | print >>f, " COMMON32_GET_breg;" |
| 161 | | |
| 162 | | if flagcondition == -1: |
| 163 | | print >>f, " COMMON32_GET_F;" |
| 164 | | |
| 165 | | print >>f, " COMMON32_GET_s12;" |
| 166 | | |
| 167 | | if ignore_a == 0: |
| 168 | | print >>f, " COMMON32_GET_areg;" |
| 169 | | elif ignore_a == 1: |
| 170 | | print >>f, " //COMMON32_GET_areg; // areg is reserved / not used" |
| 171 | | |
| 172 | | print >>f, " " |
| 173 | | print >>f, " UINT32 c;" |
| 174 | | if breg_is_dst_only == 0: |
| 175 | | print >>f, " UINT32 b;" |
| 174 | if flagcondition == -1: |
| 175 | print >>f, " COMMON32_GET_F;" |
| 176 | |
| 177 | print >>f, " COMMON32_GET_s12;" |
| 178 | |
| 179 | # areg can't be used here, it's used for s12 bits |
| 180 | |
| 176 | 181 | print >>f, " " |
| 177 | | print >>f, " /* is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense */" |
| 178 | | print >>f, " if (breg == LIMM_REG)" |
| 179 | | print >>f, " {" |
| 180 | | print >>f, " GET_LIMM_32;" |
| 181 | | print >>f, " size = 8;" |
| 182 | | print >>f, "/* got_limm = 1; */" |
| 183 | | print >>f, " b = limm;" |
| 184 | | print >>f, " }" |
| 185 | | print >>f, " else" |
| 186 | | print >>f, " {" |
| 187 | | print >>f, " b = m_regs[breg];" |
| 188 | | print >>f, " }" |
| 189 | | |
| 190 | | print >>f, " " |
| 191 | | print >>f, " c = (UINT32)S;" |
| 192 | | print >>f, " " |
| 193 | | print >>f, " /* todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) */" |
| 194 | | print >>f, " %s" % (opexecute) |
| 195 | | print >>f, " " |
| 196 | | EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler) |
| 197 | | print >>f, " return m_pc + (size >> 0);" |
| 198 | | print >>f, "}" |
| 199 | | print >>f, "" |
| 200 | | print >>f, "" |
| 182 | print >>f, " UINT32 c;" |
| 183 | if breg_is_dst_only == 0: |
| 184 | print >>f, " UINT32 b;" |
| 185 | print >>f, " " |
| 186 | print >>f, " /* is having b as LIMM valid here? LIMM vs. fixed u6 value makes no sense */" |
| 187 | print >>f, " if (breg == LIMM_REG)" |
| 188 | print >>f, " {" |
| 189 | print >>f, " GET_LIMM_32;" |
| 190 | print >>f, " size = 8;" |
| 191 | print >>f, "/* got_limm = 1; */" |
| 192 | print >>f, " b = limm;" |
| 193 | print >>f, " }" |
| 194 | print >>f, " else" |
| 195 | print >>f, " {" |
| 196 | print >>f, " b = m_regs[breg];" |
| 197 | print >>f, " }" |
| 198 | |
| 199 | print >>f, " " |
| 200 | print >>f, " c = (UINT32)S;" |
| 201 | print >>f, " " |
| 202 | print >>f, " /* todo: if areg = LIMM then there is no result (but since that register can never be read, I guess it doesn't matter if we store it there anyway?) */" |
| 203 | print >>f, " %s" % (opexecute) |
| 204 | print >>f, " %s" % (opwrite_alt) |
| 205 | print >>f, " " |
| 206 | EmitGroup04_Flaghandler(f,funcname,opname,flagcondition,flaghandler) |
| 207 | print >>f, " return m_pc + (size >> 0);" |
| 208 | print >>f, "}" |
| 209 | print >>f, "" |
| 210 | print >>f, "" |
| 201 | 211 | # the mode 0x11 m0 handler |
| 202 | 212 | print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p11_m0(OPS_32)" % (funcname) |
| 203 | | print >>f, "{" |
| 204 | | print >>f, " int size = 4;" |
| 205 | | print >>f, " arcompact_fatal(\"arcompact_handle%s_p11_m0 (%s)\\n\");" % (funcname, opname) |
| 206 | | print >>f, " return m_pc + (size >> 0);" |
| 207 | | print >>f, "}" |
| 208 | | print >>f, "" |
| 209 | | print >>f, "" |
| 213 | if ignore_a == 2: |
| 214 | print >>f, "{" |
| 215 | print >>f, " int size = 4;" |
| 216 | print >>f, " arcompact_fatal(\"illegal arcompact_handle%s_p11_m0 (ares bits already used as opcode select, can't be used as Q condition) (%s)\\n\");" % (funcname, opname) |
| 217 | print >>f, " return m_pc + (size >> 0);" |
| 218 | print >>f, "}" |
| 219 | else: |
| 220 | print >>f, "{" |
| 221 | print >>f, " int size = 4;" |
| 222 | print >>f, " arcompact_fatal(\"arcompact_handle%s_p11_m0 (%s)\\n\");" % (funcname, opname) |
| 223 | print >>f, " return m_pc + (size >> 0);" |
| 224 | print >>f, "}" |
| 225 | print >>f, "" |
| 226 | print >>f, "" |
| 210 | 227 | # the mode 0x11 m1 handler |
| 211 | 228 | print >>f, "ARCOMPACT_RETTYPE arcompact_device::arcompact_handle%s_p11_m1(OPS_32)" % (funcname) |
| 212 | | print >>f, "{" |
| 213 | | print >>f, " int size = 4;" |
| 214 | | print >>f, " arcompact_fatal(\"arcompact_handle%s_p11_m1 (%s)\\n\");" % (funcname, opname) |
| 215 | | print >>f, " return m_pc + (size >> 0);" |
| 216 | | print >>f, "}" |
| 217 | | print >>f, "" |
| 218 | | print >>f, "" |
| 229 | if ignore_a == 2: |
| 230 | print >>f, "{" |
| 231 | print >>f, " int size = 4;" |
| 232 | print >>f, " arcompact_fatal(\"illegal arcompact_handle%s_p11_m1 (ares bits already used as opcode select, can't be used as Q condition) (%s)\\n\");" % (funcname, opname) |
| 233 | print >>f, " return m_pc + (size >> 0);" |
| 234 | print >>f, "}" |
| 235 | else: |
| 236 | print >>f, "{" |
| 237 | print >>f, " int size = 4;" |
| 238 | print >>f, " arcompact_fatal(\"arcompact_handle%s_p11_m1 (%s)\\n\");" % (funcname, opname) |
| 239 | print >>f, " return m_pc + (size >> 0);" |
| 240 | print >>f, "}" |
| 241 | print >>f, "" |
| 242 | print >>f, "" |
| 219 | 243 | |
| 220 | 244 | # xxx_S b, b, u5 format opcodes |
| 221 | 245 | def EmitGroup17(f,funcname, opname, opexecute): |
| r242583 | r242584 | |
| 244 | 268 | sys.exit(1) |
| 245 | 269 | |
| 246 | 270 | |
| 247 | | EmitGroup04(f, "04_00", "ADD", "UINT32 result = b + c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 271 | EmitGroup04(f, "04_00", "ADD", "UINT32 result = b + c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 248 | 272 | |
| 249 | | EmitGroup04(f, "04_02", "SUB", "UINT32 result = b - c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 273 | EmitGroup04(f, "04_02", "SUB", "UINT32 result = b - c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 250 | 274 | |
| 251 | | EmitGroup04(f, "04_04", "AND", "UINT32 result = b & c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 252 | | EmitGroup04(f, "04_05", "OR", "UINT32 result = b | c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 253 | | EmitGroup04(f, "04_06", "BIC", "UINT32 result = b & (~c); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 254 | | EmitGroup04(f, "04_07", "XOR", "UINT32 result = b ^ c; m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 275 | EmitGroup04(f, "04_04", "AND", "UINT32 result = b & c;", "if (areg != LIMM_REG) { m_regs[areg] = result; }", "if (breg != LIMM_REG) { m_regs[breg] = result; }", 0,0, -1, EmitGroup04_Handle_NZ_Flags ) |
| 276 | EmitGroup04(f, "04_05", "OR", "UINT32 result = b | c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 277 | EmitGroup04(f, "04_06", "BIC", "UINT32 result = b & (~c);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 278 | EmitGroup04(f, "04_07", "XOR", "UINT32 result = b ^ c;", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 255 | 279 | |
| 256 | | EmitGroup04(f, "04_0a", "MOV", "UINT32 result = c; m_regs[breg] = result;", 1,1, -1, EmitGroup04_Handle_NZ_Flags ) |
| 280 | EmitGroup04(f, "04_0a", "MOV", "UINT32 result = c;", "m_regs[breg] = result;", "m_regs[breg] = result;", 1,1, -1, EmitGroup04_Handle_NZ_Flags ) # special case, result always goes to breg |
| 257 | 281 | |
| 258 | | EmitGroup04(f, "04_0f", "BSET", "UINT32 result = b | (1 << (c & 0x1f)); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 282 | EmitGroup04(f, "04_0f", "BSET", "UINT32 result = b | (1 << (c & 0x1f));", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 259 | 283 | |
| 260 | | EmitGroup04(f, "04_15", "ADD2", "UINT32 result = b + (c << 2); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 261 | | EmitGroup04(f, "04_16", "ADD3", "UINT32 result = b + (c << 3); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 284 | EmitGroup04(f, "04_15", "ADD2", "UINT32 result = b + (c << 2);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 285 | EmitGroup04(f, "04_16", "ADD3", "UINT32 result = b + (c << 3);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 262 | 286 | |
| 263 | 287 | |
| 264 | | EmitGroup04(f, "05_00", "ASL", "UINT32 result = b << (c&0x1f); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 265 | | EmitGroup04(f, "05_01", "LSR", "UINT32 result = b >> (c&0x1f); m_regs[areg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 288 | EmitGroup04(f, "05_00", "ASL", "UINT32 result = b << (c&0x1f);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 289 | EmitGroup04(f, "05_01", "LSR", "UINT32 result = b >> (c&0x1f);", "m_regs[areg] = result;", "m_regs[breg] = result;", 0,0, -1, EmitGroup04_unsupported_Flags ) |
| 266 | 290 | |
| 291 | # the 04_2f subgroup uses the same encoding, but the areg is already used as sub-opcode select, so any modes relying on areg bits for other reasons (sign, condition) (modes 10, 11m0, 11m1) are illegal. the destination is also breg not areg |
| 292 | EmitGroup04(f, "04_2f_07", "EXTB", "UINT32 result = c & 0x000000ff;", "m_regs[breg] = result;","", 2,1, -1, EmitGroup04_unsupported_Flags ) # no alt handler (invalid path) |
| 293 | |
| 294 | |
| 267 | 295 | # xxx_S b, b, u5 format opcodes |
| 268 | 296 | EmitGroup17(f, "17_00", "ASL_S", "m_regs[breg] = m_regs[breg] << (u&0x1f);" ) |
| 269 | 297 | EmitGroup17(f, "17_01", "LSR_S", "m_regs[breg] = m_regs[breg] >> (u&0x1f);" ) |