Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 10-18-2012, 02:55 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

lerxst's short answer is going to be right 99% of the time. Just cause I needed a break from hammering out these templates I compiled them both for you and generated the assembly.

Optimizations off MSVC10
Code:
	; x += y;
	; x /= 10;
	mov	edx, DWORD PTR _x$[ebp]
	add	edx, DWORD PTR _y$[ebp]
	mov	DWORD PTR _x$[ebp], edx
	mov	eax, DWORD PTR _x$[ebp]
	cdq
	mov	ecx, 10
	idiv	ecx
	mov	DWORD PTR _x$[ebp], eax

	; x = (x + y) / 10;
	mov	eax, DWORD PTR _x$[ebp]
	add	eax, DWORD PTR _y$[ebp]
	cdq
	mov	ecx, 10
	idiv	ecx
	mov	DWORD PTR _x$[ebp], eax
Optimizations on MSVC10(/O2)
Code:
	; x += y;
	; x /= 10;
	mov	eax, 1717986919
	lea	ecx, DWORD PTR [edx+edi]
	imul	ecx
	sar	edx, 2
	mov	eax, edx
	shr	eax, 31
	add	eax, edx  

	; x = (x + y) / 10;
	mov	eax, 1717986919
	lea	ecx, DWORD PTR [edx+edi]
	imul	ecx
	sar	edx, 2
	mov	eax, edx
	shr	eax, 31
	add	eax, edx
With optimizations on they both generate the same code, with them off it's slightly different.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 04:12 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3