jsr 指令

来源:互联网 发布:淘宝号点数查询 编辑:程序博客网 时间:2024/06/10 16:44
This instruction makes a delayed branch to the subroutine procedure at the specified address after
execution of the following instruction. Return address (PC + 4) is saved in PR, and a branch is
made to the address indicated by general register Rn. JSR is used in combination with RTS for

subroutine procedure calls.


JSR @Rn PC+4  PR, Rn  PC 0100nnnn00001011



    DEFINE_OPCODE(op_jsr) {
        /* jsr retAddrDst(r) target(offset)


           Places the address of the next instruction into the retAddrDst
           register and jumps to offset target from the current instruction.
        */
        int retAddrDst = vPC[1].u.operand;
        int target = vPC[2].u.operand;
        callFrame->r(retAddrDst) = vPC + OPCODE_LENGTH(op_jsr);


        vPC += target;

        NEXT_INSTRUCTION();
    }

retAddrDst is the ret address, target is branch address.



void JIT::emit_op_jsr(Instruction* currentInstruction)
{
    int retAddrDst = currentInstruction[1].u.operand;
    int target = currentInstruction[2].u.operand;
    DataLabelPtr storeLocation = storePtrWithPatch(ImmPtr(0), Address(callFrameRegister, sizeof(Register) * retAddrDst));
    addJump(jump(), target);
    m_jsrSites.append(JSRInfo(storeLocation, label()));
    printf("[FELIXS][%s][%d] m_jsrSites.size():%d.\n", __FUNCTION__, __LINE__, m_jsrSites.size());    
}



原创粉丝点击