fork(1) download
  1. uint8_t my_log2 (uint32_t op)
  2. {
  3. uint8_t res;
  4. asm(
  5. " clr r16\n"
  6. " cpse %D[op],__zero_reg__\n"
  7. " rjmp foundD%=\n"
  8. " cpse %C[op],__zero_reg__\n"
  9. " rjmp foundC%=\n"
  10. " cpse %B[op],__zero_reg__\n"
  11. " rjmp foundB%=\n"
  12. " cpse %A[op],__zero_reg__\n"
  13. " rjmp foundA%=\n"
  14. " rjmp end%=\n"
  15. "foundD%=:\n"
  16. " ori r16,0x19\n"
  17. " mov r17,%D[op]\n"
  18. " rjmp examine%=\n"
  19. "foundC%=:\n"
  20. " ori r16,0x11\n"
  21. " mov r17,%C[op]\n"
  22. " rjmp examine%=\n"
  23. "foundB%=:\n"
  24. " ori r16,0x09\n"
  25. " mov r17,%B[op]\n"
  26. " rjmp examine%=\n"
  27. "foundA%=:\n"
  28. " ori r16,0x01\n"
  29. " mov r17,%A[op]\n"
  30. "examine%=:\n"
  31. " lsr r17\n"
  32. " cpse r17,__zero_reg__\n"
  33. " inc r16\n"
  34. " lsr r17\n"
  35. " cpse r17,__zero_reg__\n"
  36. " inc r16\n"
  37. " lsr r17\n"
  38. " cpse r17,__zero_reg__\n"
  39. " inc r16\n"
  40. " lsr r17\n"
  41. " cpse r17,__zero_reg__\n"
  42. " inc r16\n"
  43. " lsr r17\n"
  44. " cpse r17,__zero_reg__\n"
  45. " inc r16\n"
  46. " lsr r17\n"
  47. " cpse r17,__zero_reg__\n"
  48. " inc r16\n"
  49. " lsr r17\n"
  50. " cpse r17,__zero_reg__\n"
  51. " inc r16\n"
  52. "end%=:\n"
  53. " mov %[res],r16\n"
  54. : [res] "=r" (res)
  55. : [op] "r" (op)
  56. : "r16", "r17"
  57. );
  58. return res;
  59. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty