please help with converting a code to assembly language
write a program using assembly language that execute the following algorithm while(n>1) { if (n is even) n:=n/2 else n:=3*n+1 }
@TuringTest please help
Some day I will know how to convert to assembly language.... but not yet :(
@timo86m please help
Have you tried stack overflow?
no i dont even, know whats that?
idk assemply.
ok thnx i am trying it nw
its assembly 8085
eish i am not getting help there
http://assembly.ynh.io/ http://stackoverflow.com/questions/2887813/from-c-to-assembly Something like this should compile using gcc: #include <stdlib.h> int main(void) { int n=1; while(n > 1) { if(n % 2 == 0) { n = n/2; } else { n = (3*n)+1; } } return EXIT_SUCCESS; }
@Lyrae how can i run this code? is it possible to use marie_cpu_simulator?
The code above is written in C and can be translated to GNU assembly using one of the links. The resulting assembly code probably won't run on the MARIE Simulator since the GNU syntax is different from the MARIE syntax, but trying anyway won't hurt nobody ;) Assuming you're using MARIE to learn about basic processor concepts such as instruction flow, then a C to assembly translator will make things harder to understand because it usually adds a lot of unnecessary instructions.
@Lyrae did you run program you gave me?
Nope not in MARIE, but it worked using a GNU assembly compiler. Oh and there should be another line above the "return EXIT_SUCCESS;" the program won't output otherwise: printf("%4.4f\n ",n);
Join our real-time social learning platform and learn together with your friends!