MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / bsr

Method bsr

tools/x86/src/x86/Bit.java:245–291  ·  view source on GitHub ↗
(FileOutputStream fos, FileOutputStream fos_init, FileOutputStream fos32, FileOutputStream fosOps_h, FileOutputStream fosOps_cpp, String bits, String functionName, String enumName, String load, boolean eaa)

Source from the content-addressed store, hash-verified

243 }
244
245 public void bsr(FileOutputStream fos, FileOutputStream fos_init, FileOutputStream fos32, FileOutputStream fosOps_h, FileOutputStream fosOps_cpp, String bits, String functionName, String enumName, String load, boolean eaa) throws IOException {
246 if (eaa) {
247 out(fosOps_h, "void common_" + functionName + "(CPU* cpu, U32 address, U32 dstReg);");
248 out(fosOps_cpp, "void common_" + functionName + "(CPU* cpu, U32 address, U32 dstReg) {");
249 } else {
250 out(fosOps_h, "void common_" + functionName + "(CPU* cpu, U32 srcReg, U32 dstReg);");
251 out(fosOps_cpp, "void common_" + functionName + "(CPU* cpu, U32 srcReg, U32 dstReg) {");
252 }
253 out(fosOps_cpp, " U"+bits+" value="+load+";");
254 out(fosOps_cpp, " cpu->fillFlagsNoZF();");
255 out(fosOps_cpp, " if (value==0) {");
256 out(fosOps_cpp, " cpu->addZF();");
257 out(fosOps_cpp, " } else {");
258 if (bits.equals("16")) {
259 out(fosOps_cpp, " U16 result = 15;");
260 out(fosOps_cpp, " while ((value & 0x8000)==0) { result--; value<<=1; }");
261 } else {
262 out(fosOps_cpp, " U32 result = 31;");
263 out(fosOps_cpp, " while ((value & 0x80000000)==0) { result--; value<<=1; }");
264 }
265 out(fosOps_cpp, " cpu->removeZF();");
266 out(fosOps_cpp, " cpu->reg[dstReg].u"+bits+"=result;");
267 out(fosOps_cpp, " }");
268 out(fosOps_cpp, "}");
269
270 out(fos, "void OPCALL normal_"+functionName+"(CPU* cpu, DecodedOp* op) {");
271 out(fos, " START_OP(cpu, op);");
272 if (eaa) {
273 out(fos, " common_"+functionName+"(cpu, eaa(cpu, op), op->reg);");
274 } else {
275 out(fos, " common_"+functionName+"(cpu, op->rm, op->reg);");
276 }
277 out(fos, " NEXT();");
278 out(fos, "}");
279 out(fos_init, "INIT_CPU("+enumName+", "+functionName+")");
280
281 out(fos32, "void dynamic_"+functionName+"(DynamicData* data, DecodedOp* op) {");
282 if (eaa) {
283 out(fos32, " calculateEaa(op, DYN_ADDRESS);");
284 out(fos32, " callHostFunction(common_" + functionName + ", false, 3, 0, DYN_PARAM_CPU, false, DYN_ADDRESS, DYN_PARAM_REG_32, true, op->reg, DYN_PARAM_CONST_32, false);");
285 } else {
286 out(fos32, " callHostFunction(common_" + functionName + ", false, 3, 0, DYN_PARAM_CPU, false, op->rm, DYN_PARAM_CONST_32, false, op->reg, DYN_PARAM_CONST_32, false);");
287 }
288 out(fos32, " data->currentLazyFlags=FLAGS_NONE;");
289 out(fos32, " INCREMENT_EIP(op->len);");
290 out(fos32, "}");
291 }
292
293 public void generateAll(FileOutputStream fos, FileOutputStream fos_init, FileOutputStream fos32, FileOutputStream fosOps_h, FileOutputStream fosOps_cpp) throws IOException {
294 bitR16(fos, fos_init, fos32, fosOps_h, fosOps_cpp, "btr16r16", "BtR16R16","", false);

Callers 3

generateAllMethod · 0.95
bsrRegMethod · 0.80

Calls 2

outMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected