You need decompiler. I'd compile it and use retargetable decompiler It is easiest way to do this specific task. I'd just like to add what this code actually does, since it's rather simple. It is designed to be used as a shellcode. A relatively standard one. It's fairly easy to follow since it's heavily commented. I am mentioning all of this because you won't be able to see many of the details in "decompiled code" which would look somethign like this:.
There is one interesting bit old shellcoding trick. For that purpose, it needs to get its address. It does that by making two calls. Calls will make new stack frames, at which point it can just pop the saved stack frame. There's also asm2c that works on assembly source code instead of executables or objects files. Sign up to join this community. The best answers are voted up and rise to the top.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Converting assembly code to c Ask Question. It was difficult for you - does it make it unwise? Ho by the way, there is really no need to demonstrate your potty mouth tendencies when somebody fails to agree with you, yes, S Smyth? It's obvious you do prefer to debate other people more than you care about considering actual arguments.
Look carefully: That thread relates to the C51 compiler; you are talking about the ARM compiler - they are not the same! Au contraire - I can imagine plenty of scenarios where someone might mistakenly believe that this could be a good way to proceed.
I can also imagine a few scenarios where it might be appropriate. Site Search User. Support forums. Share More actions Cancel. C to Assembly Converter. Thanks in advance I hope this is enough information. Reply Cancel Cancel. Up 0 Down Reply Accept answer Cancel. But why do you want to do this? They're smart enough to push and pop them in the opposite order too!
Here's how you save some preserved registers, and do some three-operand arithmetic. If you save the link register lr , and pop into the program counter pc , you'll magically return from the function!
Here's how you call a function , using "bl" or branch-and-link. This stores your return address into register lr, not the stack like x86, so you need to explicitly save main's lr so you can return there after you run. The first function argument goes into r0, just like the return value. Comparisons use the "cmp" instruction, followed by a conditional operation, exactly like x This means you can compare and then do an "addgt" add if greater-than , or a "movgt" conditional move , or a "bgt" conditional branch , etc.
Here we're printing the integers from 0 to We use r4 as the loop counter, because it is a preserved register. That tasty "blt" instruction does a branch if the compare came out less-than.
0コメント