View Single Post
Old 19 December 2013, 20:43   #1
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
Happy Best Way to Convert 32-bit Signed Value to 16 Bit?

Hi,

I need an optimisation for this:

Code:
; convert d0 from 32 to 16 bit

        move.l    #$7fff,d1
        cmp.l    d1,d0
        blt    .low_d0
        move.w    d1,d0
        bra    .ready
.low_d0        cmp.l    #$ffff8000,d0
        bgt    .ready
        move.w    #$8000,d0
.ready
I guess it converts a SIGNED 32 bit value (comes in d0) into a 16 bit value into d0. Is there a better way to do this? The problem is, values greater than $7fff should become $7fff and values smaller than $8000 should become $8000. Right?

ags

Last edited by AGS; 19 December 2013 at 20:51.
AGS is offline  
 
Page generated in 0.07446 seconds with 11 queries