Counters must have a separate input or instruction to reset. How would you assure that all counters are reset and their accumulators show 0 when you start a process?
In the begining of process you can add a routine which checks if the values of counters you want to use are zero. if ther are not then add a reset instruction. Also save the counter value to some other variable/register before setting it zero as other process might be using them. Follwing is the pseudo code of the routine to make sure counters are zero.
counter_check()
{
If counter_value is 0:
continue;
else:
counter_old = counter_value;
counter_value = 0;
}
Make a routine to set back the old value of counter
counter_setback()
{
counter_value = counter_old;
}
You can call this routine at the beginin of your process
process()
{
counter_check()
........
........
........
counter_setback()
}
I hope you get the idea. You can easily convert the pseudo code in assembly language by using conditional jumps,call, MOV and reset instructions wherever required.
Get Answers For Free
Most questions answered within 1 hours.