8x8 bit multiplication with 8-bit result, saturating at 0xFF.
- Parameters
-
i | first byte to multiply |
j | second byte to multiply |
- Returns
- the product of i * j, capping at 0xFF
Definition at line 486 of file math8.h.
486 {
487#if QMUL8_C == 1
488 unsigned p = (unsigned)i * (unsigned)j;
489 if (p > 255)
490 p = 255;
491 return p;
492#elif QMUL8_AVRASM == 1
493 asm volatile(
494
495 " mul %0, %1 \n\t"
496
497 " mov %0, r0 \n\t"
498
499 " tst r1 \n\t"
500 " breq Lnospill_%= \n\t"
501
502 " ldi %0, 0xFF \n\t"
503 "Lnospill_%=: \n\t"
504
505 " clr __zero_reg__ \n\t"
506 : "+d"(i)
507 : "r"(j)
508 : "r0", "r1");
509 return i;
510#else
511#error "No implementation for qmul8 available."
512#endif
513}
References LIB8STATIC_ALWAYS_INLINE.
Referenced by operator*().