The conjecture:
Our program will take an input on the command line and print the sequence to one and the number of iterations.
long
iterate(long x)
{
if (x % 2 == 0) {
return x/2;
}
else {
return x*3 + 1;
}
}
int
main(int argc, char* argv[])
{
long x = atol(argv[1]);
long i = 0;
while (x > 1) {
printf("%ld\n", x);
x = iterate(x);
i++;
}
printf("i = %ld\n"):
return 0;
}
Now, translate to ASM with the recipe.
Note patterns for "if" and "while" statements.