Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / device / lib / sm83 / abs.s
blobf4833403c771ca224bcd71e99181e884a13a09c3
1 ;--------------------------------------------------------------------------
2 ; abs.s
4 ; Copyright (C) 2020, Sergey Belyashov
5 ; Copyright (c) 2021, Philipp Klaus Krause
6 ; Copyright (c) 2022, Sebastian 'basxto' Riedel (sdcc@basxto.de)
8 ; This library is free software; you can redistribute it and/or modify it
9 ; under the terms of the GNU General Public License as published by the
10 ; Free Software Foundation; either version 2, or (at your option) any
11 ; later version.
13 ; This library is distributed in the hope that it will be useful,
14 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ; GNU General Public License for more details.
18 ; You should have received a copy of the GNU General Public License
19 ; along with this library; see the file COPYING. If not, write to the
20 ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21 ; MA 02110-1301, USA.
23 ; As a special exception, if you link this library with other files,
24 ; some of which are compiled with SDCC, to produce an executable,
25 ; this library does not by itself cause the resulting executable to
26 ; be covered by the GNU General Public License. This exception does
27 ; not however invalidate any other reasons why the executable file
28 ; might be covered by the GNU General Public License.
29 ;--------------------------------------------------------------------------
31 .area _CODE
33 .globl _abs
35 _abs::
36 ld c, e
37 ld b, d
38 bit 7, b
39 ret Z ; Return since positive
40 xor a ; 0
41 sub e ; 0-e
42 ld c, a
43 sbc d ; 0-e-d
44 add e ; 0-d
45 ld b, a
46 ret