Powerbasic Museum 2020-B

IT-Consultant: Charles Pegge => Assembler => Best place to post any assembler code => Topic started by: Theo Gottwald on December 19, 2009, 02:12:06 PM

Title: Fast SGN and ABS Inline Function
Post by: Theo Gottwald on December 19, 2009, 02:12:06 PM
This is of more use. You just want to know if that number is negative.
Here is FastSGN. Just needed is yesterday.

' P2 will be set to 1 in case SIGN of P1 is negative
MACRO SGN_LNG(P1,P2)
MACROTEMP POX
! MOV P2,0
! BT P1,31
! JNC POX
! MOV P2,1
POX:
END MACRO


ABS will normally be compiled from Powerbasic using Floating Point Mnemonics.
If you have a LONG value and just want to cut the Sign (http://www.jose.it-berater.org/smfforum/index.php?topic=1274.0), you can use this few lines.

MACRO ABS_LNG(P1)
MACROTEMP POS
! BT P1,31
! JNC POS
! NEG P1
POS:
END MACRO
Title: Re: Fast SGN and ABS Inline Function
Post by: Steve Hutchesson on December 20, 2009, 10:55:07 AM
 ;D

Works fine.