Ask your own question, for FREE!
Computer Science 11 Online
OpenStudy (anonymous):

please help with converting a code to assembly language

OpenStudy (anonymous):

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 }

OpenStudy (anonymous):

@TuringTest please help

OpenStudy (turingtest):

Some day I will know how to convert to assembly language.... but not yet :(

OpenStudy (anonymous):

@timo86m please help

OpenStudy (turingtest):

Have you tried stack overflow?

OpenStudy (anonymous):

no i dont even, know whats that?

OpenStudy (turingtest):

http://stackoverflow.com/

OpenStudy (anonymous):

idk assemply.

OpenStudy (anonymous):

ok thnx i am trying it nw

OpenStudy (anonymous):

its assembly 8085

OpenStudy (anonymous):

eish i am not getting help there

OpenStudy (lyrae):

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; }

OpenStudy (anonymous):

@Lyrae how can i run this code? is it possible to use marie_cpu_simulator?

OpenStudy (lyrae):

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.

OpenStudy (anonymous):

@Lyrae did you run program you gave me?

OpenStudy (lyrae):

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);

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!