fork download
  1. static inline uint16_t mul_8_8 (uint8_t op1, uint8_t op2)
  2. {
  3. uint16_t res;
  4.  
  5. asm(
  6. "mul %A[op1],%A[op2]\n"
  7. "movw %A[res],r0\n"
  8. "clr __zero_reg__\n"
  9.  
  10. : [res] "=&r" (res)
  11. : [op1] "a" (op1),
  12. [op2] "a" (op2)
  13. );
  14.  
  15. return res;
  16. }
  17.  
  18. static inline __uint24 mul_16_8 (uint16_t op1, uint8_t op2)
  19. {
  20. __uint24 res;
  21. uint8_t zero;
  22.  
  23. asm(
  24. "clr %[zero]\n"
  25. "mul %A[op1],%A[op2]\n"
  26. "movw %A[res],r0\n"
  27. "mul %B[op1],%A[op2]\n"
  28. "add %B[res],r0\n"
  29. "adc %C[res],r1\n"
  30. "clr __zero_reg__\n"
  31. : [res] "=&r" (res),
  32. [zero] "=&r" (zero)
  33. : [op1] "a" (op1),
  34. [op2] "a" (op2)
  35. );
  36.  
  37. return res;
  38. }
  39.  
  40. static inline uint32_t mul_16_16 (uint16_t op1, uint16_t op2)
  41. {
  42. uint32_t res;
  43. uint8_t zero;
  44.  
  45. asm(
  46. "clr %[zero]\n"
  47. "mul %A[op1],%A[op2]\n"
  48. "movw %A[res],r0\n"
  49. "mul %B[op1],%B[op2]\n"
  50. "movw %C[res],r0\n"
  51. "mul %B[op1],%A[op2]\n"
  52. "add %B[res],r0\n"
  53. "adc %C[res],r1\n"
  54. "adc %D[res],%[zero]\n"
  55. "mul %A[op1],%B[op2]\n"
  56. "add %B[res],r0\n"
  57. "adc %C[res],r1\n"
  58. "adc %D[res],%[zero]\n"
  59. "clr __zero_reg__\n"
  60. : [res] "=&r" (res),
  61. [zero] "=&r" (zero)
  62. : [op1] "a" (op1),
  63. [op2] "a" (op2)
  64. );
  65.  
  66. return res;
  67. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:1: error: unknown type name ‘uint16_t’
 static inline uint16_t mul_8_8 (uint8_t op1, uint8_t op2)
 ^
prog.c:1:33: error: unknown type name ‘uint8_t’
 static inline uint16_t mul_8_8 (uint8_t op1, uint8_t op2)
                                 ^
prog.c:1:46: error: unknown type name ‘uint8_t’
 static inline uint16_t mul_8_8 (uint8_t op1, uint8_t op2)
                                              ^
prog.c:18:1: error: unknown type name ‘__uint24’
 static inline __uint24 mul_16_8 (uint16_t op1, uint8_t op2)
 ^
prog.c:18:34: error: unknown type name ‘uint16_t’
 static inline __uint24 mul_16_8 (uint16_t op1, uint8_t op2)
                                  ^
prog.c:18:48: error: unknown type name ‘uint8_t’
 static inline __uint24 mul_16_8 (uint16_t op1, uint8_t op2)
                                                ^
prog.c:40:1: error: unknown type name ‘uint32_t’
 static inline uint32_t mul_16_16 (uint16_t op1, uint16_t op2)
 ^
prog.c:40:35: error: unknown type name ‘uint16_t’
 static inline uint32_t mul_16_16 (uint16_t op1, uint16_t op2)
                                   ^
prog.c:40:49: error: unknown type name ‘uint16_t’
 static inline uint32_t mul_16_16 (uint16_t op1, uint16_t op2)
                                                 ^
stdout
Standard output is empty