2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 05.08.1998
|
|
|
|
;
|
2018-05-24 03:55:40 +02:00
|
|
|
; int abs (int x);
|
|
|
|
; and
|
2000-05-28 13:40:48 +00:00
|
|
|
; CC65 runtime: negation on ints
|
|
|
|
;
|
|
|
|
|
2013-05-09 13:56:54 +02:00
|
|
|
.export negax
|
2018-05-24 03:55:40 +02:00
|
|
|
.export _abs
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2018-05-25 16:10:16 +02:00
|
|
|
_abs: cpx #$00 ; Test hi byte
|
|
|
|
bpl L1 ; Don't touch if positive
|
2013-05-09 13:56:54 +02:00
|
|
|
negax: clc
|
|
|
|
eor #$FF
|
|
|
|
adc #1
|
|
|
|
pha
|
|
|
|
txa
|
|
|
|
eor #$FF
|
|
|
|
adc #0
|
|
|
|
tax
|
|
|
|
pla
|
2018-05-24 03:55:40 +02:00
|
|
|
L1: rts
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|