Advertisement
kneefer

avr -asm

Nov 17th, 2014
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .nolist
  2. .list
  3. .dseg
  4. RAM_TAB: .byte 256
  5.  
  6. .cseg
  7. jmp RESET   ; Reset Handler
  8.  
  9. ; Interrupts vector table / change to your procedure only when needed
  10. jmp EXT_INT0    ; IRQ0 Handler
  11. jmp EXT_INT1    ; IRQ1 Handler
  12. jmp EXT_INT2    ; IRQ2 Handler
  13. jmp EXT_INT3    ; IRQ3 Handler
  14. jmp EXT_INT4    ; IRQ4 Handler
  15. jmp EXT_INT5    ; IRQ5 Handler
  16. jmp EXT_INT6    ; IRQ6 Handler
  17. jmp EXT_INT7    ; IRQ7 Handler
  18. jmp TIM2_COMP   ; Timer2 Compare Handler
  19. jmp TIM2_OVF    ;Timer2 Overflow Handler
  20. jmp TIM1_CAPT   ;Timer1 Capture Handler
  21. jmp TIM1_C0MPA  ;Timer1 CompareA Handler
  22. jmp TIM1_C0MPB  ;Timer1 CompareB Handler
  23. jmp TIM1_0VF    ;Timer1 Overflow Handler
  24. jmp TIM0_COMP   ;Timer0 Compare Handler
  25. jmp TIM0_OVF    ;Timer0 Overflow Handler
  26. jmp SPI_STC     ;SPI Transfer Complete Handler
  27. jmp USART0_RXC  ;USART0 RX Complete Handler
  28. jmp USART0_DRE  ;USART0,UDR Empty Handler
  29. jmp USART0_TXC  ;USART0 TX Complete Handler
  30. jmp ADC1        ;ADC Conversion Complete Handler
  31. jmp EE_RDY      ;EEPROM Ready Handler
  32. jmp ANA_COMP    ;Analog Comparator Handler
  33. jmp TIM1_C0MPC  ;Timer1 CompareC Handler
  34. jmp TIM3_CAPT   ;Timer3 Capture Handler
  35. jmp TIM3_COMPA  ;Timer3 CompareA Handler
  36. jmp TIM3_COMPB  ; Timer3 CompareB Handler
  37. jmp TIM3_COMPC  ;Timer3 CompareC Handler
  38. jmp TIM3_OVF    ;Timer3 Overflow Handler
  39. jmp USART1_RXC  ;USART1 RX Complete Handler
  40. jmp USART1_DRE  ;USART1,UDR Empty Handler
  41. jmp USART1_TXC  ;USART1 TX Complete Handler
  42. jmp TWI         ;Two-wire Serial Interface Interrupt Handler
  43. jmp SPM_RDY     ;SPM Ready Handler
  44.  
  45. ;//////////////////////////////////////////////////////////////////////////////
  46. EXT_INT0:   ; IRQ0 Handler
  47. EXT_INT1:   ; IRQ1 Handler
  48. EXT_INT2:   ; IRQ2 Handler
  49. EXT_INT3:   ; IRQ3 Handler
  50. EXT_INT4:   ; IRQ4 Handler
  51. EXT_INT5:   ; IRQ5 Handler
  52. EXT_INT6:   ; IRQ6 Handler
  53. EXT_INT7:   ; IRQ7 Handler
  54. TIM2_COMP:  ; Timer2 Compare Handler
  55. TIM2_OVF:   ;Timer2 Overflow Handler
  56. TIM1_CAPT:  ;Timer1 Capture Handler
  57. TIM1_C0MPA: ;Timer1 CompareA Handler
  58. TIM1_C0MPB: ;Timer1 CompareB Handler
  59. TIM1_0VF:   ;Timer1 Overflow Handler
  60. TIM0_COMP:  ;Timer0 Compare Handler
  61. TIM0_OVF:   ;Timer0 Overflow Handler
  62. SPI_STC:    ;SPI Transfer Complete Handler
  63. USART0_RXC: ;USART0 RX Complete Handler
  64. USART0_DRE: ;USART0,UDR Empty Handler
  65. USART0_TXC: ;USART0 TX Complete Handler
  66. ADC1:       ;ADC Conversion Complete Handler
  67. EE_RDY:     ;EEPROM Ready Handler
  68. ANA_COMP:   ;Analog Comparator Handler
  69. TIM1_C0MPC: ;Timer1 CompareC Handler
  70. TIM3_CAPT:  ;Timer3 Capture Handler
  71. TIM3_COMPA: ;Timer3 CompareA Handler
  72. TIM3_COMPB: ; Timer3 CompareB Handler
  73. TIM3_COMPC: ;Timer3 CompareC Handler
  74. TIM3_OVF:   ;Timer3 Overflow Handler
  75. USART1_RXC: ;USART1 RX Complete Handler
  76. USART1_DRE: ;USART1,UDR Empty Handler
  77. USART1_TXC: ;USART1 TX Complete Handler
  78. TWI:        ;Two-wire Serial Interface Interrupt Handler
  79. SPM_RDY:    ;SPM Ready Handler
  80. reti        ; return from all no used
  81.  
  82. ;//////////////////////////////////////////////////////////////////////////////
  83. ; Program start
  84. RESET:
  85.  
  86. cli         ; disable all interrupts
  87. ;  Set stack pointer to top of RAM
  88. ldi R16, HIGH(RAMEND)
  89. out SPH, R16
  90. ldi R16, LOW(RAMEND)
  91. out SPL, R16
  92.  
  93.  
  94. ldi r16, 0x00       ;do r16 ładujemy 00000000 binarnie
  95. out DDRA, r16      
  96. ldi r16, 0xFF       ;do r16 ładujemy 11111111 binarnie
  97. out DDRB, r16      
  98.  
  99. ;ładujemy adres tablicy ROM
  100. ldi r16, byte3(ROM_TAB<<1)
  101. out RAMPZ, r16
  102.  
  103. ldi r30, low(ROM_TAB<<1)
  104. ldi r31, high(ROM_TAB<<1)
  105. ldi r28, low(RAM_TAB)
  106. ldi r29, high(RAM_TAB)
  107.  
  108. kopiujZRomDoRam:
  109.     elpm r16, Z+
  110.     cpi r16, 0
  111.     brne kopiujBajt
  112.     elpm r16, Z
  113.     cpi r16, 0
  114.     breq koniec
  115.     sbiw Z, 1
  116.     elpm r16, Z+
  117.  
  118. kopiujBajt:
  119.     st Y+, r16              ;kopiujemy wartość i przechodzimy do kolejnej komórki tablicy ramu
  120.     jmp kopiujZRomDoRam     ;jeśli większa od 0 , czyli mamy więcej niż 255 elementów
  121.  
  122. koniec:
  123.     rjmp koniec
  124.  
  125. ROM_TAB: .db 0x74, 0x74, 0x74, 0x73, 0x00, 0x74, 0x74, 0x74, 0x00, 0x00
  126.  
  127. .exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement