Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/avr/udivmodqi4.S
35290 views
//===------------ udivmodqi4.S - uint8 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 {uint8, uint8} __udivmodqi4(uint8, uint8)`.11// The uint8 quotient is returned via R24, and the uint8 remainder is returned12// via R25, while R23 is clobbered.13//14//===----------------------------------------------------------------------===//1516.text17.align 21819.globl __udivmodqi420.type __udivmodqi4, @function2122__udivmodqi4:23sub r25, r25 ; Initialize the remainder to zero.24ldi r23, 9 ; Only loop 8 rounds for uint8.2526__udivmodqi4_loop:27adc r24, r2428dec r2329breq __udivmodqi4_end30adc r25, r2531cp r25, r22 ; Compare with the divisor.32brcs __udivmodqi4_loop33sub r25, r22 ; Subtract the divisor.34rjmp __udivmodqi4_loop3536__udivmodqi4_end:37com r24 ; The uint8 quotient is returned via R24.38ret ; The uint8 remainder is returned via R25.394041