Absolute Value ofAssembler/MC68000

This gem returns the absoulte value of any integer value you may send to the routine. This is the smallest version and probably the fastest (atleast on a MC68000 and the number is negative), neg.l is 6 cycles, branch taken 10, not taken 8.

;
; returns the absolute value of input
;
; input:
;   d0.l = in value
;
; output:
;   d0.l = absolute value of in value
; 
; destroys:
;   flags
;

.localloop
        neg.l   d0
        bmi     .localloop
Gem writer: John Eckerdal
last updated: 1998-03-16