Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/avr/divmodqi4.S
35290 views
1
//===------------- divmodqi4.S - sint8 div & mod --------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// As described at
10
// https://gcc.gnu.org/wiki/avr-gcc#Exceptions_to_the_Calling_Convention, the
11
// prototype is `struct {sint8, sint8} __divmodqi4(sint8, sint8)`.
12
// The sint8 quotient is returned via R24, and the sint8 remainder is returned
13
// via R25, while registers R23/Rtmp and bit T in SREG are clobbered.
14
//
15
//===----------------------------------------------------------------------===//
16
17
.text
18
.align 2
19
20
#ifdef __AVR_TINY__
21
.set __tmp_reg__, 16
22
#else
23
.set __tmp_reg__, 0
24
#endif
25
26
.globl __divmodqi4
27
.type __divmodqi4, @function
28
29
__divmodqi4:
30
bst r24, 7
31
mov __tmp_reg__, r24
32
eor __tmp_reg__, r22
33
sbrc r24, 7
34
neg r24
35
sbrc r22, 7
36
neg r22
37
rcall __udivmodqi4 ; Call __udivmodqi4 to do real calculation.
38
brtc __divmodqi4_1
39
neg r25
40
41
__divmodqi4_1:
42
sbrc __tmp_reg__, 7
43
neg r24
44
ret ; Return quotient via R24 and remainder via R25.
45
46