]> git.sur5r.net Git - cc65/blob - libsrc/runtime/negabs.s
Merge pull request #740 from laubzega/master
[cc65] / libsrc / runtime / negabs.s
1 ;
2 ; Ullrich von Bassewitz, 05.08.1998
3 ;
4 ; int abs (int x);
5 ; and
6 ; CC65 runtime: negation on ints
7 ;
8
9         .export         negax
10         .export         _abs
11
12 _abs:   cpx     #$00            ; Test hi byte
13         bpl     L1              ; Don't touch if positive
14 negax:  clc
15         eor     #$FF
16         adc     #1
17         pha
18         txa
19         eor     #$FF
20         adc     #0
21         tax
22         pla
23  L1:    rts
24
25
26