NASM - The Netwide Assembler
NASM Forum => Other Discussion => Topic started by: hockey97 on June 15, 2014, 06:31:42 PM
-
Hi, I am learning ASM x86 and got this code for an example. I would like if someone could convert it from ASM to C or C++. Also explain what each line does.
I am new here and I know the basics of ASM. I am now trying to learn how to translate ASM code to C or a higher language.
Here's the code:
UnknownFunction:
MOV EDI,EDI
PUSH EBP
MOV EBP,ESP
MOV EAX,DWORD PTR SS:[EBP+8]
XOR EDX,EDX
LEA ECX,DWORD PTR DS:[EAX+4]
MOV DWORD PTR DS:[EAX],EDX
MOV DWORD PTR DS:[ECX+4],ECX
MOV DWORD PTR DS:[ECX],ECX
MOV DWORD PTR DS:[EAX+C],ECX
MOV ECX,DWORD PTR SS:[EBP+C]
MOV DWORD PTR DS:[EAX+18],ECX
MOV ECX,DWORD PTR SS:[EBP+10]
MOV DWORD PTR DS:[EAX+1C],ECX
MOV ECX,DWORD PTR SS:[EBP+14]
MOV DWORD PTR DS:[EAX+20],ECX
MOV ECX,DWORD PTR SS:[EBP+18]
MOV DWORD PTR DS:[EAX+14],EDX
MOV DWORD PTR DS:[EAX+10],EDX
MOV DWORD PTR DS:[EAX+24],ECX
POP EBP
RETN 14
All I know is that it's pushing stuff off and on a stack. It has pointers and uses exclusive or conditional statement.
I am guessing that RETN 14 is the same as returning 0 in C or C++.
This whole thing is a function.
-
I am sure, you won't learn assembly programming by the use of reverse engeneering!
-
I am guessing that RETN 14 is the same as returning 0 in C or C++.
I think, Your "quessing" is a bit wrong. It pops 14 bytes off the stack and only then - returns. Returns value that is stored into eax.
Thanks, bye.
-
I am guessing that RETN 14 is the same as returning 0 in C or C++.
I think, Your "quessing" is a bit wrong. It pops 14 bytes off the stack and only then - returns. Returns value that is stored into eax.
Thanks, bye.
So, then how would you write that in C or C++?
-
I have seen a couple applications that can do that but the code you will get will not be anything similar to the original code. I just complete an assignment about conversion of ASM to C with the help of genuine essay writing service (http://www.essayscouncil.com/essays.php), but i can't follow the method described in it. I think that to call assembly from C, you simply use the normal C syntax for a function call. This assumes, of course, that the assembly function was written using the C calling conventions.
-
I have seen a couple applications that can do that but the code you will get will not be anything similar to the original code. I just complete an assignment about conversion of ASM to C with the help of genuine essay writing service (http://www.essayscouncil.com/essays.php), but i can't follow the method described in it. I think that to call assembly from C, you simply use the normal C syntax for a function call. This assumes, of course, that the assembly function was written using the C calling conventions.
I'm absolutely agree with you .
-
Your assigned essay writer will handle every aspect of formatting to ensure that you receive buy narrative essay (http://www.buy-essay-online.com/) and submit a properly formatted essay.