File: tc2.s

package info (click to toggle)
simulavr 1.0.0%2Bgit20160221.e53413b-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 5,748 kB
  • sloc: cpp: 35,491; python: 6,991; ansic: 3,567; makefile: 1,072; sh: 653; asm: 414; tcl: 320
file content (35 lines) | stat: -rw-r--r-- 1,043 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <avr/io.h>
#include <avr/interrupt.h>

#undef _SFR_IO8
#define _SFR_IO8(x) (x)
#undef _SFR_IO16
#define _SFR_IO16(x) (x)


.global main
main:
    ldi r16, 0xff          ; all pins output
    out DDRB, r16          ; all pins output
    ldi r16, 0x01          ; one pin on
    out PORTB, r16         ; initial only 1 pin 

    ldi r16, (1<<UDRIE)    ; lets generate a usart data register empty irq
    out UCSRB, r16         ; fire hardware irq, but i flag is not set
    ldi r17, 0x55

    sei                    ; now the irq is pending
    out PORTB, r17         ; if this instruction is executed, we will see 0x55 on portb!

; normaly never execute any of the following instructions, we caught into irq handler
    ldi r17, 0x0f;         ; if irq will not be executed or comes back
    out PORTB, r17         ; we see 0x0f on port b which should not happen
    ret                    ; this will result in going back to ctors_end -> exit

.global USART_UDRE_vect
USART_UDRE_vect:
.global stopsim
stopsim:
   rjmp USART_UDRE_vect