Jump to content
Tuts 4 You
Sign in to follow this  
unix

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

Rate this topic

Recommended Posts

unix

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 (see edit history)

Share this post


Link to post
Share on other sites
metr0

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.

Share this post


Link to post
Share on other sites
ghandi

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 (see edit history)

Share this post


Link to post
Share on other sites
metr0

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

Share this post


Link to post
Share on other sites
unix

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.

Share this post


Link to post
Share on other sites
diablo2oo2

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

Share this post


Link to post
Share on other sites
by:70

c:

if (value1 == value2)

{

value3 = 5;

}

Fasm:(http://flatassembler.net/)

format PE GUI 4.0

entry start

value1 equ 1

value2 equ 1

value3 db ?

start:

mov eax,value1

cmp eax,value2

jne lable

mov eax,5

mov byte [value3],al

lable:

; exit

Edited by by:70 (see edit history)

Share this post


Link to post
Share on other sites
unix

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 (see edit history)

Share this post


Link to post
Share on other sites
unix

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

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×
×
  • Create New...