Page 2 of 3

Posted: Thu Sep 29, 2005 2:23 pm
by blueznl
42

Posted: Thu Sep 29, 2005 2:25 pm
by Trond
Lebostein wrote:

Code: Select all

result.l = val - (val+val)
result.l = val - val - val
result.l = 0 - val
result.l = -val
:roll:
Those are all you can think of? :lol: How about this?

Code: Select all

result.l = 4294967296 - num.l
result.l = num + 4294967296

Posted: Thu Sep 29, 2005 6:39 pm
by horst

Code: Select all

NEG val

Posted: Thu Sep 29, 2005 6:52 pm
by Trond

Code: Select all

NOT num
num + 1

Posted: Thu Sep 29, 2005 8:18 pm
by va!n
horst wrote:

Code: Select all

NEG val
@horst:
thanks really cool to use direct ASM! I know there was such a command for 680x0 but i didnt remember its name nor how its named on x86! Thanks for sharing! 10points :wink:

Posted: Thu Sep 29, 2005 8:44 pm
by techjunkie
Dare2 wrote:@Psychophanta,

Stop criticising and start contributing!

:P :D
Hehe... I kind off agree... :lol: but [thinking] then I have to contribute too... Well, I'll come up with something! :D

Posted: Thu Sep 29, 2005 8:46 pm
by Bonne_den_kule
LOL

Posted: Thu Sep 29, 2005 8:46 pm
by Psychophanta
Criticism is also a way to contribute :wink:

Posted: Thu Sep 29, 2005 11:22 pm
by Dare2
techjunkie wrote:.. but [thinking] then I have to contribute too... Well, I'll come up with something! :D
Shhhhhhh! Or I'll have to stop criticising and start contributing. :D

@Psychophanta:

I am really disappointed. Usually you respond with all guns blazing! :)

Posted: Fri Sep 30, 2005 8:18 am
by Psychophanta
Dare2 wrote:@Psychophanta:
I am really disappointed. Usually you respond with all guns blazing! :)
Bahh!, that's only a possible point of view, but you can be sure it's in any case, a susceptible and wrong point of view :)
My wish is guns to dissappear forever :wink:

Posted: Fri Sep 30, 2005 9:57 pm
by djes

Code: Select all

#ECSTATIC		=	$8000000
#PLASTIC		=	$4000000
#FANTASTIC	=	$2000000
#SURE				=	$0000333
#NOTSURE		=	$0666000

;***

Procedure.l lInvert_Value(lval.l, lflags.l)

	Protected FVAL_TO_CONVERT.f, FTEMP_RESULT.f, LFINAL_RESULT.l

	FVAL_TO_CONVERT.f=lval

	If lflags&#ECSTATIC=#ECSTATIC
		FTEMP_RESULT=-FVAL_TO_CONVERT
	EndIf

	If lflags&#PLASTIC=#PLASTIC
		FTEMP_RESULT=Sin(3.1416/2)*Cos(3.1416)*Sqr(1)*FVAL_TO_CONVERT
	EndIf

	If lflags&#FANTASTIC=#FANTASTIC
		;TOFIX : need to be rewritten by a senior programmer coz I had some bogz
		FTEMP_RESULT=ValF("-"+StrF(FVAL_TO_CONVERT+0.00000)+"0000")
	EndIf

	LFINAL_RESULT=FTEMP_RESULT

	If lflags&#NOTSURE=#NOTSURE
		ProcedureReturn LFINAL_RESULT*0
	EndIf

	If lflags&#NOTSURE=#SURE
		ProcedureReturn LFINAL_RESULT*0
	EndIf

	If lflags&#SURE=#NOTSURE
		ProcedureReturn LFINAL_RESULT*0
	EndIf

	If lflags&#SURE=#SURE
		ProcedureReturn LFINAL_RESULT
	EndIf

EndProcedure

;***

Debug lInvert_Value(24,#ECSTATIC|#SURE)			; returns	-24
Debug lInvert_Value(-318,#PLASTIC|#SURE)		; returns	318 
Debug lInvert_Value(-0,#FANTASTIC|#NOTSURE)	; returns		0 
End
:D



sad that tabs aren't supported by this forum :wink:

Posted: Fri Sep 30, 2005 10:00 pm
by Dr. Dri
asm output code (/commented) :shock:

Code: Select all

; a = -a
  MOV    ebx,dword [v_a]
  NEG    ebx
  MOV    dword [v_a],ebx
working "inlined" asm code :!:

Code: Select all

a = 1
!NEG [v_a]
Debug a
I think "NEG a" is faster than using ebx but maybe i'm wrong... It may be optimized as "a + 1" becomes "INC a".

Dri :idea:

Posted: Fri Sep 30, 2005 10:22 pm
by Fred
True, it can be easily optimized, i put it on the todo list

Posted: Sat Oct 01, 2005 4:39 am
by va!n
Fred wrote:True, it can be easily optimized, i put it on the todo list
:)

Posted: Sat Oct 01, 2005 11:21 am
by Dr. Dri
Fred wrote:True, it can be easily optimized, i put it on the todo list
:D

Dri ^^