[Done ]Improve/optimize ProcedureReturn
Posted: Wed Jun 21, 2006 2:07 pm
I know this is not the first time this has been braught up,
but since I was messing with /COMMENTED while teaching myself more asm I noticed this and have some suggestions on improvements as well.
The following code:
becomes this:
ideally it should be this right?:
If this can't easily be done, how about this instead?:
since as far as I can tell RET is several cpu cycles less than a JMP.
Oh in case anyone wonders this is a Abs() routine for longs I use.
Obviously it would be ideal to have the above AbsL() asm fully inline like Abs() currently is
but since I was messing with /COMMENTED while teaching myself more asm I noticed this and have some suggestions on improvements as well.
The following code:
Code: Select all
Procedure.l AbsL(value)
!MOV eax,[p.v_value]
!CDQ
!XOR eax,edx
!SUB eax,edx
ProcedureReturn
EndProcedure
Code: Select all
_Procedure0:
PS0=4
p.v_value equ esp+PS0+0
MOV eax,[p.v_value]
CDQ
XOR eax,edx
SUB eax,edx
JMP _EndProcedure1
XOR eax,eax
_EndProcedure1:
RET 4
Code: Select all
_Procedure0:
PS0=4
p.v_value equ esp+PS0+0
MOV eax,[p.v_value]
CDQ
XOR eax,edx
SUB eax,edx
RET 4
Code: Select all
_Procedure0:
PS0=4
p.v_value equ esp+PS0+0
MOV eax,[p.v_value]
CDQ
XOR eax,edx
SUB eax,edx
RET 4
XOR eax,eax
_EndProcedure1:
RET 4
Oh in case anyone wonders this is a Abs() routine for longs I use.
Obviously it would be ideal to have the above AbsL() asm fully inline like Abs() currently is
