/** * Top module to extract the whole string into final OpCode * * Input: * String instructions,with appropriate arguments * * Return OpCode in int type */ unsigned int interpret(String *instruction){ stringTrimLeft(instruction); String *instString = stringRemoveWordNotContaining(instruction," "); char *instChar = stringSubstringInChar(instString,0,instString->length); instructionTable inst = getInstruction(instChar); if(inst.type == FDA_TYPE) return inst.opCode | FDA(instruction); else if(inst.type == FBA_TYPE) return inst.opCode | FBA(instruction); else if(inst.type == FA_TYPE) return inst.opCode | FA(instruction); else if(inst.type == FSFD_TYPE) return inst.opCode | FSFD(instruction); else if(inst.type == N_TYPE) return inst.opCode | N(instruction); else if(inst.type == NS_TYPE) return inst.opCode | NS(instruction); else if(inst.type == S_TYPE) return inst.opCode | S(instruction); else if(inst.type == K_TYPE) return inst.opCode | K(instruction); else if(inst.type == FK_TYPE) return inst.opCode | FK(instruction); else Throw(ERR_ILLEGAL_ARGUMENT); }
void test_fsfd_should_mock_and_move_to_operand2_0x02480154(void){ int value; Text *text = textNew("71"); String *str = stringNew(text); extractValue_ExpectAndReturn(str, 0x154); extractValue_ExpectAndReturn(str, 0x248); value = FSFD(str); TEST_ASSERT_EQUAL_HEX32(value, 0x02480154); }
void test_fsfd_operand1_ERR_EMPTY_ARGUMENT_should_mock_and_throw_error(void){ int value; int e; Text *text = textNew(""); String *str = stringNew(text); extractValue_ExpectAndThrow(str, 3); Try{ value = FSFD(str); }Catch(e){ TEST_ASSERT_EQUAL(ERR_EMPTY_ARGUMENT, e); } }