summaryrefslogtreecommitdiff
path: root/n/avr/modules/math/fixed/fixed_mul_f824.avr.S
diff options
context:
space:
mode:
Diffstat (limited to 'n/avr/modules/math/fixed/fixed_mul_f824.avr.S')
-rw-r--r--n/avr/modules/math/fixed/fixed_mul_f824.avr.S10
1 files changed, 8 insertions, 2 deletions
diff --git a/n/avr/modules/math/fixed/fixed_mul_f824.avr.S b/n/avr/modules/math/fixed/fixed_mul_f824.avr.S
index 853dcb6..9da807d 100644
--- a/n/avr/modules/math/fixed/fixed_mul_f824.avr.S
+++ b/n/avr/modules/math/fixed/fixed_mul_f824.avr.S
@@ -51,10 +51,11 @@
; avoided.
; All multiplications results are added together. If the result is negative,
; do the sign extension (the sbc instructions).
+; Result is rounded to the nearest value.
;
; Perfs:
-; 91 cycles
-; 10989 per second, per MHz
+; 96 cycles
+; 10416 per second, per MHz
#define dummy1 r25
#define dummy0 r24
@@ -111,6 +112,11 @@ fixed_mul_f824_asm:
add m1, r0
adc m2, r1
adc m3, z
+; Rounding, m0 is dropped.
+ ldi m0, 0x80
+ add m1, m0
+ adc m2, z
+ adc m3, z
; Shift.
movw m0, m2
; Upper word.