View Single Post
Old 31 May 2021, 01:02   #1
buzzybee
Registered User
 
Join Date: Oct 2015
Location: Landsberg / Germany
Posts: 526
Fast way of getting absolute value

Hi guys!

Wonder what you guys think of my code. Its purpose is to convert the value in register d7 to its absolute value:

Code:
	swap d7		; fetch x-acceleration
	tst.w d7	; test if negative
	smi d4		; Yes? Set d4
	ext.w d4	; create polarity converter
	eor d4,d7	; convert polarity (if x-acc is negative)
d7 is loaded with one longword-operation prior to this code, and contains x- (upper word) and y-acceleration (lower word) of a given sprite object. Code works. But this code is repeatedly executed a few times during one frame [in Reshoot Proxima 3], and I have a feeling that this can be optimized for speed. Any thoughts?
buzzybee is offline  
 
Page generated in 0.05510 seconds with 11 queries