I need your opinion!!! ASM vs Plain C++

Started by
10 comments, last by HellRaiZer 21 years, 2 months ago
quote:Original post by Anonymous Poster
Those movs you found unnecessary are infact not. They get executed at the same time becuase none of the relies on the other.


quote:
mov eax, DWORD PTR _this$[ebp]
mov DWORD PTR [eax], 0

mov ecx, DWORD PTR _this$[ebp]
mov DWORD PTR [ecx+4], 0

mov edx, DWORD PTR _this$[ebp]
mov DWORD PTR [edx+8], 0


Huh?

Height Map Editor | Eternal lands

[edited by - Raduprv on February 1, 2003 7:21:44 PM]
Advertisement
quote:
mov eax, DWORD PTR _this$[ebp]
mov DWORD PTR [eax], 0
mov ecx, DWORD PTR _this$[ebp]
mov DWORD PTR [ecx+4], 0
mov edx, DWORD PTR _this$[ebp]
mov DWORD PTR [edx+8], 0


This is not good code. Your code did look better.

I''d be interested in seeing the complete listing after you added the inline assembly (as someone pointed out, perhaps something is being generated before and after the inline block?) I don''t use inline assembly, so I''m not too familiar with how MSVC handles it.

The key to acheiving instruction-level parallelism on modern OOO processors as I understand them is to eliminate dependency chains. Putting as many instructions which can be executed simultaneously without side effects close together is a good idea.

Don''t overestimate MSVC''s optimizer or any optimizer for that matter. Use assembly where it would really make an improvement (profile!) and make sure that you do a good job of it. Personally, I prefer having separate assembly source files so as to keep my C code as easily portable as possible.



----
Bart
----Bart

This topic is closed to new replies.

Advertisement