Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / device / lib / stm8-large / _modulong.s
blob99a83764eb782d722a29f320eb4ca1dff56d13ef
1 ;--------------------------------------------------------------------------
2 ; _modulong.s
4 ; Copyright (C) 2014, Ben Shi
6 ; This library is free software; you can redistribute it and/or modify it
7 ; under the terms of the GNU General Public License as published by the
8 ; Free Software Foundation; either version 2, or (at your option) any
9 ; later version.
11 ; This library is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ; GNU General Public License for more details.
16 ; You should have received a copy of the GNU General Public License
17 ; along with this library; see the file COPYING. If not, write to the
18 ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
19 ; MA 02110-1301, USA.
21 ; As a special exception, if you link this library with other files,
22 ; some of which are compiled with SDCC, to produce an executable,
23 ; this library does not by itself cause the resulting executable to
24 ; be covered by the GNU General Public License. This exception does
25 ; not however invalidate any other reasons why the executable file
26 ; might be covered by the GNU General Public License.
27 ;--------------------------------------------------------------------------
29 .globl __modulong
31 .area CODE
32 __modulong:
33 sub sp, #3
34 ; device/lib/_modulong.c: 342: unsigned char count = 0;
35 clr (0x03, sp)
36 ; device/lib/_modulong.c: 344: while (!MSB_SET(b))
37 clr (0x01, sp)
38 __modulong_00103:
39 ld a, (0x0b, sp)
40 sll a
41 clr a
42 rlc a
43 tnz a
44 jrne __modulong_00117
45 ; device/lib/_modulong.c: 346: b <<= 1;
46 ldw y, (0x0d, sp)
47 ldw x, (0x0b, sp)
48 sllw y
49 rlcw x
50 ldw (0x0d, sp), y
51 ldw (0x0b, sp), x
52 ; device/lib/_modulong.c: 347: if (b > a)
53 ldw x, (0x09, sp)
54 cpw x, (0x0d, sp)
55 ld a, (0x08, sp)
56 sbc a, (0x0c, sp)
57 ld a, (0x07, sp)
58 sbc a, (0x0b, sp)
59 jrnc __modulong_00102
60 ; device/lib/_modulong.c: 349: b >>=1;
61 ldw y, (0x0d, sp)
62 ldw x, (0x0b, sp)
63 srlw x
64 rrcw y
65 ldw (0x0d, sp), y
66 ldw (0x0b, sp), x
67 ; device/lib/_modulong.c: 350: break;
68 jra __modulong_00117
69 __modulong_00102:
70 ; device/lib/_modulong.c: 352: count++;
71 inc (0x01, sp)
72 ld a, (0x01, sp)
73 ld (0x03, sp), a
74 jra __modulong_00103
75 ; device/lib/_modulong.c: 354: do
76 __modulong_00117:
77 ld a, (0x03, sp)
78 ld (0x02, sp), a
79 __modulong_00108:
80 ; device/lib/_modulong.c: 356: if (a >= b)
81 ldw x, (0x09, sp)
82 subw x, (0x0d, sp)
83 ld a, (0x08, sp)
84 sbc a, (0x0c, sp)
85 ld yl, a
86 ld a, (0x07, sp)
87 sbc a, (0x0b, sp)
88 jrc __modulong_00107
89 ; device/lib/_modulong.c: 357: a -= b;
90 ldw (0x09, sp), x
91 ld yh, a
92 ldw (0x07, sp), y
93 __modulong_00107:
94 ; device/lib/_modulong.c: 358: b >>= 1;
95 ldw y, (0x0d, sp)
96 ldw x, (0x0b, sp)
97 srlw x
98 rrcw y
99 ldw (0x0d, sp), y
100 ldw (0x0b, sp), x
101 ; device/lib/_modulong.c: 360: while (count--);
102 ld a, (0x02, sp)
103 dec (0x02, sp)
104 tnz a
105 jrne __modulong_00108
106 ; device/lib/_modulong.c: 362: return a;
107 ldw x, (0x09, sp)
108 ldw y, (0x07, sp)
109 addw sp, #3
110 retf