1 //===------------ mulhi3.S - int8 multiplication --------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // The corresponding C code is something like:
11 // char __mulqi3(char A, char B) {
17 // A = ((unsigned char) A) >> 1;
22 // __mulqi3 has special ABI, as the implementation of libgcc, the result is
23 // returned via R24, while Rtmp and R22 are clobbered.
25 //===----------------------------------------------------------------------===//
37 .type __mulqi3, @function
40 clr __tmp_reg__ ; S = 0;
44 breq __mulqi3_end ; while (A != 0) {
45 sbrc r24, 0 ; if (A & 1)
46 add __tmp_reg__, r22 ; S += B;
47 add r22, r22 ; B <<= 1;
48 lsr r24 ; A = ((unsigned char) A) >> 1;
49 rjmp __mulqi3_loop ; }