Lets assume the function in pseudocode.
int abs_diff(int l, int r) {
int abs_diff = abs(l - r);
return abs_diff;
}
I was able to implement this function in assembler.
abs_diff:
sub $t1, $a0, $a1
sra $t2,$t1,31
xor $t1,$t1,$t2
sub $v0,$t1,$t2
jr $ra #Return
Now I want to implement an extension of this function in assembler. The pseudocode for the new function is
int abs_diff_new(int r1, int g1, int b1, int r2, int g2, int b2) {
int abs_diff_new = abs(r1-r2) + abs(g1-g2) + abs(b1-b2);
return abs_diff_new;
}
I don't know how to implement this functions, since this new function requires 6 arguments, but MIPS only provides 4 registers ($a0-$a3) to pass the arguments. How can i modify my abs_diff ?