I'm stuck on a stack. I have to call to a function in mips-32 assembly code, in which I have to evaluate a Hermite polynomial just by giving the n and the x as parameters. It must be done using recursion.
I've tried to set 2 base cases H0 and H1, using them both at the same time, but I can't identify the sequence and the pile draw that makes the code clear.
Follows the code:
li $t2,2
recursive_hermite: #H(n,x,___,___)
bge $a0,$t5,more_than_2
#### base
#### case
jr $ra ##<--- this takes us to the operation of the value
more_than_2:
## here you are supposed to store the values on stack
## (such as return address and n values)
addi $a0,$a0,-1 ##you must decrease n (or increase I'm not sure)
jal recursive_hermite ##once they are stored, you just recall
### operations of value
## $f12 must contain the whole value
jr $ra ####this one returns to the main
Does anyone know how to solve this problem?
I see you are in trouble. Judging the way you wrote the question it seems like your assigment is due tomorrow, so we have to work things fast.
You remind me of myself 20 years back, good old times when c++ was just being born and assembly was all the rage. I have heard of those cringy MIPS emulators like QTspim, you should avoid them and work like a real man with some real handy hardware.
Here is my tip: you have to store the partial results of the polinomials tested in every recursion. To do that you have to control time and space, which have to be perfectly balanced like all things should be.
If I was you I would start working in your step by step execution of the program so you can check what the register values are.
It is dangerous to go alone, take this:
Hope it helps, if you need, ask for further explanation here, its been directly taken out of my Final grade Work, and in my Masters.
PD: It is licensed under the GPL, so be careful on what you do with it, FBI might be looking for you. Love :)