Jump to content
Tuts 4 You

(M)ASM <-> C/C++


unix

Recommended Posts

Hello,

i wanted to ask if someone knows something like a comparison-list of (m)asm and c/ c++ functions. I understand both languages and can write and read it, but a list which compares functions would be nice.

What i mean for example:

ASM

mov eax, value1
cmp eax, value2
//code
mov eax, 5
//code
mov value3, eax

C

if (value1 == value2)
{
value3 = 5;
}

Maybe the examples don't match very well but it should be something similar i guess (cant test it right now..).

So what i am asking is if there is somewhere a list where i can see how common functions/ instructions look like in asm <-> c?

It would be nice to see quickly when i have some asm instructions how the appopriate c function would look like (if-else, loops, strlen, memcpy, ...)

Edited by unix
Link to comment

Hacker Disassembling Uncovered has a section called "Identifying Key Structures of High-Level Languages", you'll find similar information in other publications as well. Or you could do it on your own, code a small C program and analyze the disassembly.

Link to comment

Sometimes it is harder though, if using VC++ because of MS optimization. What you write in your C/C++ code will differ greatly or only a little, depending on your optimization settings.

HR,

Ghandi

Edited by ghandi
Link to comment

Reminds me of VC++ "optimizing" a "mov dword ptr [00000000], eax" into my code... and no, the C code didn't contain any static zero pointer. ;)

Link to comment

Thank you, guess i will look for a copy of Hacker Disassembling Uncovered as i wanted to read it anyway. Thanks :)

Sometimes it is harder though, if using VC++ because of MS optimization. What you write in your C/C++ code will differ greatly or only a little, depending on your optimization settings.

I tried that first but got "stuck" because of this.

Link to comment

this discussion is not about masm like the topic says.

if i would code that in masm it would look like in c

//c

if (value1 == value2)

{

value3 = 5;

}

;---masm---

mov eax,value2

.if value1 == eax

mov value3,5

.endif

Link to comment

Thanks for your replys. :)

@diablo2oo2: Can you recommend a good book or other resource about "real" masm programming?

I tried Art of Assembly Language but it seems to be High Level Assembly..

edit: except iczelions and gobbits from arteam of course.

Edited by unix
Link to comment

Thanks by:70, i like the two references ;)

Iczelion's-Tutorial's are great too, but i was looking for other ones as i am already working on them ;)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...