![]() |
Ackermann Function
Can anyone help me in writing Ackermann Function function in assembly language. I'm using MIPS and the function needs to be Recursive.
h**p://img41.imageshack.us/img41/9972/akermannfunction.jpg |
Re: Ackermann Function
go easy on the fonts buddy
|
Re: Ackermann Function
We won't write it for you. How far have you got and where are you stuck?
|
Re: Ackermann Function
here guys I was able to write the C program .. but m having trouble writing the MIPS version of it... I'm having difficulty using the stack pointer and what not...
this is what I have so far C code Code:
#include<stdio.h>Code:
|
Re: Ackermann Function
this is how far I have reached
Code:
main: |
Re: Ackermann Function
k..now m stuck here
Code:
main: |
Re: Ackermann Function
Well, if you're in your final semester, you should already know that the exact error message is rather essential in helping identifying the cause of the problem. So why not tell us what the error message is instead of just saying "error on this line".
|
Re: Ackermann Function
my expertise is not in programming but in analog circuit designing, DSP etc... I dont want the solution, just a better explanation why's there a error on that line
|
Re: Ackermann Function
Well, how do we know if we don't know what the error is.
OK, let me say it straight. TELL US THE ERROR. |
Re: Ackermann Function
main:
li $a0, 3 # m = 3 li $a1, 3 # n = 3 jal ackermann move $a0, $v0 li $v0, 1 syscall li $v0, 10 syscall ackermann: addi $sp, $sp, -12 # creating space on the stack (3 columns) sw $a0, 4($sp) # saving origional m sw $a1, 8($sp) # saving origional n sw $ra, 0($sp) # saving origional caller return address ERROR HERE case_one: # m = 0 bne $a0, 0, case_two add $v0, $a1, 1 j exit case_two: # n = 0 bne $a1, 0, case_three addi $a0, $a0, -1 li $a1, 1 jal case_one case_three: addi $a1, $a1, -1 jal ackermann addi $a1, $v0, 0 addi $a0, $a0, -1 jal case_one exit: lw $ra, 0($sp) addi $sp, $sp, 12 jr $ra |
| All times are GMT +5.5. The time now is 08:45. |