Advertisement
Guest User

Untitled

a guest
May 6th, 2025
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ldi r16, 25
  2.  
  3. mov r8, r16
  4.  
  5. call IsEightTendie
  6.  
  7. pop r1
  8.  
  9. call EndLoop
  10.  
  11. .org 0x26
  12.  
  13. IsEightTendie:
  14.  
  15. sts 0x0100, r16
  16.  
  17. sts 0x0101, r17 ; this might be considered safe but who knows where the stack pointer
  18.  
  19. sts 0x0102, r1 ; could be before executing this subroutine in some other application
  20.  
  21. pop r16
  22.  
  23. pop r17
  24.  
  25. push r8 ;r8 is on the stack preserving it's value
  26.  
  27. lsr r8
  28.  
  29. brbs 0, IsNotDivisible
  30.  
  31. lsr r8
  32.  
  33. brbs 0, IsNotDivisible
  34.  
  35. lsr r8
  36.  
  37. brbs 0, IsNotDivisible
  38.  
  39. pop r8
  40.  
  41. eor r1, r1 ;sets this to zero
  42.  
  43. com r1 ; sets to 0xFF
  44.  
  45. push r1 ; r1 is on the stack ;return FF
  46.  
  47. push r17
  48.  
  49. push r16
  50.  
  51. lds r16, 0x0100
  52.  
  53. lds r17, 0x0101
  54.  
  55. lds r1, 0x0102
  56.  
  57. ret
  58.  
  59. .org 0x75
  60.  
  61. IsNotDivisible: ;ret 0
  62.  
  63. pop r8
  64.  
  65. eor r1, r1
  66.  
  67. push r1
  68.  
  69. push r17
  70.  
  71. push r16
  72.  
  73. lds r16, 0x0100
  74.  
  75. lds r17, 0x0101
  76.  
  77. lds r1, 0x0102
  78.  
  79. ret
  80.  
  81. .org 0x100
  82.  
  83. EndLoop:
  84.  
  85. rjmp EndLoop
Tags: AVR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement