Prusa MINI Firmware overview
math.h File Reference

Go to the source code of this file.

Functions

static FORCE_INLINE uint16_t MultiU24X32toH16 (uint32_t longIn1, uint32_t longIn2)
 
static FORCE_INLINE uint16_t MultiU16X8toH16 (uint8_t charIn1, uint16_t intIn2)
 

Function Documentation

◆ MultiU24X32toH16()

static FORCE_INLINE uint16_t MultiU24X32toH16 ( uint32_t  longIn1,
uint32_t  longIn2 
)
static

Marlin 3D Printer Firmware Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]

Based on Sprinter and grbl. Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. Optimized math functions for AVR

38  {
39  uint8_t tmp1;
40  uint8_t tmp2;
41  uint16_t intRes;
42  __asm__ __volatile__(
43  A("clr %[tmp1]")
44  A("mul %A[longIn1], %B[longIn2]")
45  A("mov %[tmp2], r1")
46  A("mul %B[longIn1], %C[longIn2]")
47  A("movw %A[intRes], r0")
48  A("mul %C[longIn1], %C[longIn2]")
49  A("add %B[intRes], r0")
50  A("mul %C[longIn1], %B[longIn2]")
51  A("add %A[intRes], r0")
52  A("adc %B[intRes], r1")
53  A("mul %A[longIn1], %C[longIn2]")
54  A("add %[tmp2], r0")
55  A("adc %A[intRes], r1")
56  A("adc %B[intRes], %[tmp1]")
57  A("mul %B[longIn1], %B[longIn2]")
58  A("add %[tmp2], r0")
59  A("adc %A[intRes], r1")
60  A("adc %B[intRes], %[tmp1]")
61  A("mul %C[longIn1], %A[longIn2]")
62  A("add %[tmp2], r0")
63  A("adc %A[intRes], r1")
64  A("adc %B[intRes], %[tmp1]")
65  A("mul %B[longIn1], %A[longIn2]")
66  A("add %[tmp2], r1")
67  A("adc %A[intRes], %[tmp1]")
68  A("adc %B[intRes], %[tmp1]")
69  A("lsr %[tmp2]")
70  A("adc %A[intRes], %[tmp1]")
71  A("adc %B[intRes], %[tmp1]")
72  A("mul %D[longIn2], %A[longIn1]")
73  A("add %A[intRes], r0")
74  A("adc %B[intRes], r1")
75  A("mul %D[longIn2], %B[longIn1]")
76  A("add %B[intRes], r0")
77  A("clr r1")
78  : [intRes] "=&r" (intRes),
79  [tmp1] "=&r" (tmp1),
80  [tmp2] "=&r" (tmp2)
81  : [longIn1] "d" (longIn1),
82  [longIn2] "d" (longIn2)
83  : "cc"
84  );
85  return intRes;
86 }

◆ MultiU16X8toH16()

static FORCE_INLINE uint16_t MultiU16X8toH16 ( uint8_t  charIn1,
uint16_t  intIn2 
)
static
92  {
93  uint8_t tmp;
94  uint16_t intRes;
95  __asm__ __volatile__ (
96  A("clr %[tmp]")
97  A("mul %[charIn1], %B[intIn2]")
98  A("movw %A[intRes], r0")
99  A("mul %[charIn1], %A[intIn2]")
100  A("add %A[intRes], r1")
101  A("adc %B[intRes], %[tmp]")
102  A("lsr r0")
103  A("adc %A[intRes], %[tmp]")
104  A("adc %B[intRes], %[tmp]")
105  A("clr r1")
106  : [intRes] "=&r" (intRes),
107  [tmp] "=&r" (tmp)
108  : [charIn1] "d" (charIn1),
109  [intIn2] "d" (intIn2)
110  : "cc"
111  );
112  return intRes;
113 }
A
#define A(CODE)
Definition: macros.h:75
uint8_t
const uint8_t[]
Definition: 404_html.c:3