Let's look at what and
does. From Wikipedia:
and $d,$s,$t $d = $s & $t
So $v
in your code will be set to $a0
ANDed with 0. Well, anything ANDed with 0 is 0. So if you have 32 bit registers, wouldn't you want something like
clr0: lui $a1, 65535 # start constructing the constant, so upper bits of v1 are all 1
ori $a1, $a1, 65534 # finish constructing the constant, so that only 0th bit is 0
and $v0, $a0, $a1 #mask out the 0th bit of a0
jr $ra
That would mean that all of the bits, except for the 0th bit, are left as is, and the 0th bit is forced to 0.
I just edited this to take into account that andi
only takes a 16 bit constant - so first we construct the constant in a free register, then AND it. I don't have a compiler handy, nor do I remember which MIPS registers are free for the function to party on, but something very similar to this should get the job done.
And here's a small driver program to call clr0
main: li $a0, 5
and $v0, $v0, 0
jal clr0 #after this, investigate the value of $v0.
jr $ra # retrun to caller