
Patrick B. answered 08/16/21
Math and computer tutor/teacher
there's a translator on godbolt dot org
there are many versions of the ARM assembler from which to choose...
It is interesting to see how the assembler handles the recursion with two push calls...
I went from C++ to ARM v 11 clang.
Here's the source for the factorial.
using namespace std;
#include <iostream>
long factorial ( long n)
{
long longFactorialReturn=-1;
if (n==0)
{
longFactorialReturn=1;
}
else
{
longFactorialReturn = n * factorial(n-1);
cout << longFactorialReturn << endl;
}
return(longFactorialReturn);
}
int main()
{
long n=5;
cout << "Factorial : n! = " << factorial(n) << endl;
}


Patrick B.
Students need to do both: be able to create from scratch AND translate08/16/21
David W.
It is CLEARLY the case that books and professors TEACH students to build programs from the ground up -- NOT to TRANSLATE high-level programs into assembler. That is unfortunate because translation is a great way to learn (because the code usually works rather than requiring endless debugging). If there were many, many TRANSLATIONS of high level code, students could better prepare for initial work assignments -- nearly all junior-level programming jobs involve modifications of existing code rather than generation of new code. Further, this assignment misses an excellent opportunity to use WHILE ( >=0 ) instead of WHILE ( !=0 ) -- if you don't know why, you have years of frustration ahead of you !08/16/21