diff --git a/cMIPS/include/handlers.s b/cMIPS/include/handlers.s index 38789a900e99478a3b72d38822c03706f63b2ae3..e02fef5b485330e46d6f0e78c5441849687926c8 100644 --- a/cMIPS/include/handlers.s +++ b/cMIPS/include/handlers.s @@ -178,6 +178,24 @@ startCount: #---------------------------------------------------------------- + #================================================================ + # stopCount disables the COUNT register, returns new CAUSE + # CAUSE.dc <= 1 to disable counting + #---------------------------------------------------------------- + .text + .set noreorder + .global stopCount + .ent stopCount +stopCount: + mfc0 $v0, c0_cause + lui $v1, 0x0800 + or $v0, $v0, $v1 + jr $ra + mtc0 $v0, c0_cause + .end stopCount + #---------------------------------------------------------------- + + #================================================================ # readCount returns the value of the COUNT register #---------------------------------------------------------------- diff --git a/cMIPS/tests/count.c b/cMIPS/tests/count.c index 0b1ef6ec4e9323296879116f02e96ad8bd0cfe49..464c0006055643ab7de54e9e7480dec986a4fdf8 100644 --- a/cMIPS/tests/count.c +++ b/cMIPS/tests/count.c @@ -1,7 +1,7 @@ //------------------------------------------------------------------------- // test if COUNT register counts up monotonically // returns error if the time to compute every 11th element of the Fibonacci -// sequence, as measured by COUNT is not monotonically increasing +// sequence, as measured by COUNT, is not monotonically increasing //------------------------------------------------------------------------- #include "cMIPS.h"