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