45 lines · plain
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-exception6//7//===----------------------------------------------------------------------===//8//9// As described at10// https://gcc.gnu.org/wiki/avr-gcc#Exceptions_to_the_Calling_Convention, the11// prototype is `struct {sint8, sint8} __divmodqi4(sint8, sint8)`.12// The sint8 quotient is returned via R24, and the sint8 remainder is returned13// via R25, while registers R23/Rtmp and bit T in SREG are clobbered.14//15//===----------------------------------------------------------------------===//16 17 .text18 .align 219 20#ifdef __AVR_TINY__21 .set __tmp_reg__, 1622#else23 .set __tmp_reg__, 024#endif25 26 .globl __divmodqi427 .type __divmodqi4, @function28 29__divmodqi4:30 bst r24, 731 mov __tmp_reg__, r2432 eor __tmp_reg__, r2233 sbrc r24, 734 neg r2435 sbrc r22, 736 neg r2237 rcall __udivmodqi4 ; Call __udivmodqi4 to do real calculation.38 brtc __divmodqi4_139 neg r2540 41__divmodqi4_1:42 sbrc __tmp_reg__, 743 neg r2444 ret ; Return quotient via R24 and remainder via R25.45