Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/avr/divmodhi4.S
35290 views
//===------------- divmodhi4.S - sint16 div & mod -------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// As described at9// https://gcc.gnu.org/wiki/avr-gcc#Exceptions_to_the_Calling_Convention, the10// prototype is `struct {sint16, sint16} __divmodhi4(sint16, sint16)`.11// The sint16 quotient is returned via R23:R22, and the sint16 remainder is12// returned via R25:R24, while registers R21/R26/27/Rtmp and bit T in SREG13// are clobbered.14//15//===----------------------------------------------------------------------===//1617.text18.align 21920#ifdef __AVR_TINY__21.set __tmp_reg__, 1622#else23.set __tmp_reg__, 024#endif2526.globl __divmodhi427.type __divmodhi4, @function2829__divmodhi4:30bst r25, 731mov __tmp_reg__, r2332brtc __divmodhi4_a33com __tmp_reg__34rcall __divmodhi4_b3536__divmodhi4_a:37sbrc r23, 738rcall __divmodhi4_c39rcall __udivmodhi4 ; Call __udivmodhi4 to do real calculation.40sbrc __tmp_reg__, 741rcall __divmodhi4_c42brtc __divmodhi4_exit4344__divmodhi4_b:45com r2546neg r2447sbci r25, 25548ret ; Return quotient via R23:R22 and remainder via R25:R24.4950__divmodhi4_c:51com r2352neg r2253sbci r23, 2555455__divmodhi4_exit:56ret ; Return quotient via R23:R22 and remainder via R25:r24.575859