OpenCores
URL https://opencores.org/ocsvn/RISCMCU/RISCMCU/trunk

Subversion Repositories RISCMCU

[/] [RISCMCU/] [trunk/] [asm/] [counter.lst] - Blame information for rev 28

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 yapzihe
 
2
AVRASM ver. 1.30  COUNTER.ASM Sun Jul 07 15:58:37 2002
3
 
4
 
5
         ; This program is for simulation purpose
6
         ; It demo how the MCU output 3, 2 and 1 to each port (Port B, Port C and Port D)
7
         ; There are 3 approaches used in accomplishing the above task
8
 
9
          .include "riscmcu.inc"
10
 
11
         ;***** I/O Register Definitions
12
 
13
          .equ  SREG    =$3f
14
          .equ  GIMSK   =$3b
15
          .equ  TIMSK   =$39
16
          .equ  TIFR    =$38
17
          .equ  MCUCR   =$35
18
          .equ  TCCR0   =$33
19
          .equ  TCNT0   =$32
20
 
21
          .equ  PORTB   =$18
22
          .equ  DDRB    =$17
23
          .equ  PINB    =$16
24
          .equ  PORTC   =$15
25
          .equ  DDRC    =$14
26
          .equ  PINC    =$13
27
          .equ  PORTD   =$12
28
          .equ  DDRD    =$11
29
          .equ  PIND    =$10
30
 
31
 
32
         ;***** Bit Definitions
33
 
34
          .equ  INT0    =6
35
 
36
          .equ  TOIE0   =1
37
 
38
          .equ  TOV0    =1
39
 
40
          .equ  ISC01   =1
41
          .equ  ISC00   =0
42
 
43
          .equ  CS02    =2
44
          .equ  CS01    =1
45
          .equ  CS00    =0
46
 
47
          .def  ZP      =r30
48
 
49
 
50
          .def  B = r16
51
          .def  C = r17
52
          .def  D = r18
53
          .def  TEMP = r19
54
 
55
 
56
 
57
000000 c002             rjmp    reset           ; reset vector
58
000001 9508             ret                     ; external interrupt vertor(not use)
59
000002 9508             ret                     ; timer overflow interrupt vertor (not use)
60
 
61
 
62
          reset:
63
000003 2733             clr     TEMP            ; r19 = 00
64
000004 9530             com     TEMP            ; r19 = FF
65
000005 bb37             out     DDRB,TEMP       ; set all Port B pins as output
66
000006 bb34             out     DDRC,TEMP       ; set all Port C pins as output
67
000007 bb31             out     DDRD,TEMP       ; set all Port D pins as output
68
 
69
 
70
 
71
         ; Approach 1, output to Port B
72
 
73
000008 e003             ldi     B,3             ; r16 = 03
74
000009 bb08      again1:        out     PORTB,B         ; Port B now output 03
75
00000a 950a             dec     B               ; r16 = r16 - 1
76
00000b 3000             cpi     B,0             ; if r16 = 0,
77
00000c f7e1             brne    again1          ;   branch to again1
78
 
79
 
80
 
81
         ; Approach 2, output to Port C
82
 
83
00000d 2733             clr     TEMP            ; r19 = 00
84
00000e 9513             inc     C               ; r17 = 01
85
00000f 9513             inc     C               ; r17 = 02
86
000010 9513             inc     C               ; r17 = 03
87
000011 bb15      again2:        out     PORTC,C         ; Port C now output 03
88
000012 5011             subi    C,1             ; r17 = r17 - 1
89
000013 1313             cpse    C,TEMP          ; if r17 != r19 (means if r17 != 0),
90
000014 cffc             rjmp    again2          ;    branch to again2
91
 
92
 
93
 
94
         ; Approach 3, output to Port D
95
 
96
000015 2722             clr     D               ; r18 = 00
97
000016 5f2d             subi    D,-3            ; r18 = r18 - (-3) = 03
98
000017 bb22      again3:        out     PORTD,D         ; Port D now output 03
99
000018 952a             dec     D               ; r18 = r18 -1
100
000019 b73f             in      TEMP,SREG       ; transfer the value of SR to R19
101
00001a ff31             sbrs    TEMP,1          ; if bit 1 in R19 (the Z-flag) is set, skip the next instruction
102
00001b cffb             rjmp    again3          ;    else branch to again3
103
 
104
 
105
 
106
00001c cfff      end:   rjmp    end             ; Branch Forever
107
00001d 9478             sei                     ; (Set I-Bit in SR) This 2 instructions won't execute
108
00001e 9468             set                     ; (Set T-Bit in SR)   even they are fetched to the IR
109
 
110
 
111
 
112
 
113
 
114
Assembly complete with no errors.

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.