Implement the following multiclock cycle assembly instructio
Implement the following multi-clock cycle assembly instruction by generating the associated 13-bit control words and building a sequential circuit that will output the control words in sequence after each clock cycle. Use the op-code table from Problem 2. R_i leftarrow 4 * R_i + R_j
Solution
// This part is Platform dependent!
#ifdef WIN32
inline int CPP_SpinLock::TestAndSet(int* pTargetAddress,
int nValue)
{
__asm
{
mov edx, dword ptr [pTargetAddress]
mov eax, nValue
lock xchg eax, dword ptr [edx]
}
// mov = 2 CPU cycle
// lock = 1 CPU cycle
// xchg = 4 CPU cycles
}
#endif // WIN32
