MCPcopy Create free account
hub / github.com/WheretIB/nullc / GenCodeCmdIndex

Function GenCodeCmdIndex

NULLC/CodeGen_X86.cpp:1738–1783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1736
1737
1738void GenCodeCmdIndex(VMCmd cmd)
1739{
1740 EMIT_COMMENT("IMUL int");
1741
1742 EMIT_OP_REG(o_pop, rEAX); // Take index
1743 if(cmd.cmd == cmdIndex)
1744 {
1745 EMIT_OP_REG_NUM(o_cmp, rEAX, cmd.argument);
1746 }else{
1747 EMIT_OP_REG_RPTR(o_mov, rECX, sDWORD, rESP, 4); // take size
1748 EMIT_OP_REG_REG(o_cmp, rEAX, rECX);
1749 }
1750 EMIT_OP_LABEL(o_jb, aluLabels, false);
1751#ifdef __linux
1752 EMIT_OP_NUM(o_int, 3);
1753#else
1754 EMIT_OP_REG_REG(o_xor, rECX, rECX);
1755 EMIT_OP_NUM(o_int, 3);
1756#endif
1757 EMIT_LABEL(aluLabels, false);
1758 aluLabels++;
1759
1760 EMIT_OP_REG(o_pop, rEDX); // Take address
1761
1762 // Multiply it
1763 if(cmd.helper == 1)
1764 {
1765 EMIT_OP_REG_REG_MULT_REG_NUM(o_lea, rESI, sNONE, rEAX, 1, rEDX, 0);
1766 }else if(cmd.helper == 2){
1767 EMIT_OP_REG_REG_MULT_REG_NUM(o_lea, rESI, sNONE, rEAX, 2, rEDX, 0);
1768 }else if(cmd.helper == 4){
1769 EMIT_OP_REG_REG_MULT_REG_NUM(o_lea, rESI, sNONE, rEAX, 4, rEDX, 0);
1770 }else if(cmd.helper == 8){
1771 EMIT_OP_REG_REG_MULT_REG_NUM(o_lea, rESI, sNONE, rEAX, 8, rEDX, 0);
1772 }else if(cmd.helper == 16){
1773 EMIT_OP_REG_NUM(o_shl, rEAX, 4);
1774 EMIT_OP_REG_REG_MULT_REG_NUM(o_lea, rESI, sNONE, rEAX, 1, rEDX, 0);
1775 }else{
1776 EMIT_OP_REG_NUM(o_imul, rEAX, cmd.helper);
1777 EMIT_OP_REG_REG_MULT_REG_NUM(o_lea, rESI, sNONE, rEAX, 1, rEDX, 0);
1778 }
1779 if(cmd.cmd == cmdIndex)
1780 EMIT_OP_REG(o_push, rESI);
1781 else
1782 EMIT_OP_RPTR_REG(o_mov, sDWORD, rESP, 0, rESI);
1783}
1784
1785void GenCodeCmdCopyDorL(VMCmd cmd)
1786{

Callers

nothing calls this directly

Calls 10

EMIT_COMMENTFunction · 0.85
EMIT_OP_REGFunction · 0.85
EMIT_OP_REG_NUMFunction · 0.85
EMIT_OP_REG_RPTRFunction · 0.85
EMIT_OP_REG_REGFunction · 0.85
EMIT_OP_LABELFunction · 0.85
EMIT_OP_NUMFunction · 0.85
EMIT_LABELFunction · 0.85
EMIT_OP_RPTR_REGFunction · 0.85

Tested by

no test coverage detected