staticinlineintidex(swaddr_t eip, int (*decode)(swaddr_t), void (*execute)(void)) { /* eip is pointing to the opcode */ len = decode(eip + 1); execute(); return len + 1; // "1" for opcode }
/* in 'nemu/include/cpu/exec/helper.h' there is a reference of idex: idex(eip, concat4(decode_, type, _, SUFFIX), do_execute); do_execute is a self-defined function, defined in every instruction's .h template files. see what's concat4: in 'nemu/include/macro.h': #define str_temp(x) #x #define str(x) str_temp(x) #define concat_temp(x, y) x ## y #define concat(x, y) concat_temp(x, y) #define concat3(x, y, z) concat(concat(x, y), z) #define concat4(x, y, z, w) concat3(concat(x, y), z, w) #define concat5(x, y, z, v, w) concat4(concat(x, y), z, v, w) It remains to be a problem. */
staticinlineintget_instr_len() { return len + 1; }
/* So what's Operands? in 'nemu/include/cpu/decode/operand.h': typedef struct { uint32_t opcode; bool is_data_size_16; Operand src, dest, src2; } Operands; About the use of is_data_size_16: I guess it probably be like this: ops_decoded.is_data_size_16 ? concat(name, _w) : concat(name, _l). And src and dest and src2... it seems reasonable now. */