void Processor::execute()
{
	StageBuffer buf;
    Result result;
        
	for (unsigned int i=0; i < instructions.size(); i++)
	{
		buf.rel.reset();
		buf.address = -1;
        ID(buf);
        ALU(buf);
        if(buf.IR.isMemInstruction())
        {
            currentMem = buf;
            result = applyAllRules(currentMem, prevMem);
			if(result != ignored)
				fout<< currentMem.PC+1 << ":" << prevMem.PC+1 << "=" << getStringFromResult(result) << "\n";
			currentMem.amIdirty = reg[currentMem.IR.sReg1].dirtyNo;
            prevMem = currentMem;
        }
        PC++;
	}

	fout.close();
}
Example #2
0
/**
 * \cond oldruleengine
 * \fn msiApplyAllRules(msParam_t *actionParam, msParam_t* reiSaveFlagParam, msParam_t* allRuleExecFlagParam, ruleExecInfo_t *rei)
 *
 * \brief  This microservice executes all applicable rules for a given action name.
 *
 * \module core
 *
 * \since pre-2.1
 *
 * \author  Arcot Rajasekar
 * \date    2008
 *
 * \note Normal operations of the rule engine is to stop after a rule (one of the alternates)
 *   completes successfully. But in some cases, one may want the rule engine to try all
 *   alternatives and succeed in as many as possible. Then by firing that rule under this
 *   microservice all alternatives are tried.
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[in] actionParam - a msParam of type STR_MS_T which is the name of an action to be executed.
 * \param[in] reiSaveFlagParam - a msParam of type STR_MS_T which is 0 or 1 value used to
 *    check if the rei structure needs to be saved at every rule invocation inside the
 *    execution. This helps to save time if the rei structure is known not to be
 *    changed when executing the underlying rules.
 * \param[in] allRuleExecFlagParam - allRuleExecFlagParam is a msParam of type STR_MS_T which
 *    is 0 or 1 whether the "apply all rule" condition applies only to the actionParam
 *    invocation or is recursively done at all levels of invocation of every rule inside the execution.
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
 * \endcond
**/
int
msiApplyAllRules( msParam_t *actionParam, msParam_t* reiSaveFlagParam,
                  msParam_t* allRuleExecFlagParam, ruleExecInfo_t *rei ) {
    int i;
    char *action;
    int reiSaveFlag;
    int allRuleExecFlag;

    action = ( char * ) actionParam->inOutStruct;
    reiSaveFlag = atoi( ( char * ) reiSaveFlagParam->inOutStruct );
    allRuleExecFlag = atoi( ( char * ) allRuleExecFlagParam->inOutStruct );
    i = applyAllRules( action, rei->msParamArray, rei, reiSaveFlag, allRuleExecFlag );
    return( i );

}