1 |
2 |
MichaelA |
MPASM 5.50 M16C5X_TST.ASM 6-22-2013 10:14:54 PAGE 1
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
LOC OBJECT CODE LINE SOURCE TEXT
|
5 |
|
|
VALUE
|
6 |
|
|
|
7 |
|
|
00001 ;**************************************************************************
|
8 |
|
|
00002 ; M16C5x_Tst.ASM
|
9 |
|
|
00003 ;
|
10 |
|
|
00004 ; This sample program runs on most all PIC devices. To ensure
|
11 |
|
|
00005 ; proper execution, replace the processor specified in the LIST directive
|
12 |
|
|
00006 ; with your target processor.
|
13 |
|
|
00007 ;
|
14 |
|
|
00008 ; Program execution starts at location H'50'. The loop routine executes
|
15 |
|
|
00009 ; seven times. The routines Reduce and Double execute one time for each
|
16 |
|
|
00010 ; loop.
|
17 |
|
|
00011 ;
|
18 |
|
|
00012 ; After the loop executes seven times, the program repeats execution from
|
19 |
|
|
00013 ; the beginning.
|
20 |
|
|
00014 ;
|
21 |
|
|
00015 ;
|
22 |
|
|
00016 ; Variable Initial Description
|
23 |
|
|
00017 ; Value
|
24 |
|
|
00018 ;--------------------------------------------------------------------------
|
25 |
|
|
00019 ; CountDown 255 Decreases to 128 by subtracting Doubler
|
26 |
|
|
00020 ; Doubler 1 Increases to 128 by adding to itself
|
27 |
|
|
00021 ; OuterLoop 7 Decrements by one to 0
|
28 |
|
|
00022 ;
|
29 |
|
|
00023 ;
|
30 |
|
|
00024 ; The program generates the following values:
|
31 |
|
|
00025 ;
|
32 |
|
|
00026 ; Cycle # CountDown Doubler OuterLoop
|
33 |
|
|
00027 ; 0 255 1 7
|
34 |
|
|
00028 ; 1 254 2 6
|
35 |
|
|
00029 ; 2 252 4 5
|
36 |
|
|
00030 ; 3 248 8 4
|
37 |
|
|
00031 ; 4 240 16 3
|
38 |
|
|
00032 ; 5 224 32 2
|
39 |
|
|
00033 ; 6 192 64 1
|
40 |
|
|
00034 ; 7 128 128 0
|
41 |
|
|
00035 ;
|
42 |
|
|
00036 ;**************************************************************************
|
43 |
|
|
00037
|
44 |
|
|
00038 LIST P=16F59, R=DEC
|
45 |
|
|
00039
|
46 |
|
|
00040 ;--------------------------------------------------------------------------
|
47 |
|
|
00041 ; Set ScratchPadRam here. If you are using a PIC16C5X device, use:
|
48 |
|
|
00042 ;ScratchPadRam EQU 0x10
|
49 |
|
|
00043 ; Otherwise, use:
|
50 |
|
|
00044 ;ScratchPadRam EQU 0x20
|
51 |
|
|
00045 ;--------------------------------------------------------------------------
|
52 |
|
|
00046
|
53 |
|
|
00000010 00047 ScratchPadRam EQU 0x10
|
54 |
|
|
00048
|
55 |
|
|
00049 ;--------------------------------------------------------------------------
|
56 |
|
|
00050 ; Variables
|
57 |
|
|
00051 ;--------------------------------------------------------------------------
|
58 |
|
|
00052
|
59 |
|
|
00000010 00053 CountDown EQU ScratchPadRam+0
|
60 |
|
|
MPASM 5.50 M16C5X_TST.ASM 6-22-2013 10:14:54 PAGE 2
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
LOC OBJECT CODE LINE SOURCE TEXT
|
64 |
|
|
VALUE
|
65 |
|
|
|
66 |
|
|
00000011 00054 Doubler EQU ScratchPadRam+1
|
67 |
|
|
00000012 00055 OuterLoop EQU ScratchPadRam+2
|
68 |
|
|
00056
|
69 |
|
|
00057
|
70 |
|
|
00058 ;--------------------------------------------------------------------------
|
71 |
|
|
00059 ; Program Code
|
72 |
|
|
00060 ;--------------------------------------------------------------------------
|
73 |
|
|
00061 ;--------------------------------------------------------------------------
|
74 |
|
|
00062 ; Set the reset vector here. If you are using a PIC16C5X device, use:
|
75 |
|
|
00063 ; ORG
|
76 |
|
|
00064 ; Otherwise, use:
|
77 |
|
|
00065 ; ORG 0
|
78 |
|
|
00066 ;--------------------------------------------------------------------------
|
79 |
|
|
00067
|
80 |
|
|
07FF 00068 ORG H'7FF'
|
81 |
|
|
Message[306]: Crossing page boundary -- ensure page bits are set.
|
82 |
|
|
07FF 0A50 00069 GOTO Start
|
83 |
|
|
00070
|
84 |
|
|
00071 ;--------------------------------------------------------------------------
|
85 |
|
|
00072 ; Main Program
|
86 |
|
|
00073 ;--------------------------------------------------------------------------
|
87 |
|
|
00074
|
88 |
|
|
0050 00075 ORG H'50'
|
89 |
|
|
00076
|
90 |
|
|
0050 00077 Start
|
91 |
|
|
0050 0CFF 00078 MOVLW 255 ; Initialize the variables to
|
92 |
|
|
0051 0030 00079 MOVWF CountDown ; their starting values.
|
93 |
|
|
0052 0C01 00080 MOVLW 1
|
94 |
|
|
0053 0031 00081 MOVWF Doubler
|
95 |
|
|
0054 0C07 00082 MOVLW 7
|
96 |
|
|
0055 0032 00083 MOVWF OuterLoop
|
97 |
|
|
0056 00084 Loop
|
98 |
|
|
0056 095A 00085 CALL Reduce ; Perform the inner portion of
|
99 |
|
|
0057 02F2 00086 DECFSZ OuterLoop,f ; the loop.
|
100 |
|
|
0058 0A56 00087 GOTO Loop
|
101 |
|
|
00088
|
102 |
|
|
0059 0A50 00089 GOTO Start ; Repeat the whole thing.
|
103 |
|
|
00090
|
104 |
|
|
00091 ;--------------------------------------------------------------------------
|
105 |
|
|
005A 00092 Reduce
|
106 |
|
|
005A 03B1 00093 SWAPF Doubler,f ; Reduce CountDown by the
|
107 |
|
|
005B 0391 00094 SWAPF Doubler,w ; value of Doubler. Then
|
108 |
|
|
005C 03B1 00095 SWAPF Doubler,f ; call the doubling routine.
|
109 |
|
|
005D 00B0 00096 SUBWF CountDown,f
|
110 |
|
|
005E 0960 00097 CALL Double
|
111 |
|
|
005F 0800 00098 RETLW 0
|
112 |
|
|
00099
|
113 |
|
|
00100 ;--------------------------------------------------------------------------
|
114 |
|
|
0060 00101 Double
|
115 |
|
|
0060 03B1 00102 SWAPF Doubler,f ; Double the value of Doubler
|
116 |
|
|
0061 0391 00103 SWAPF Doubler,w ; by adding it to itself.
|
117 |
|
|
0062 03B1 00104 SWAPF Doubler,f
|
118 |
|
|
0063 01F1 00105 ADDWF Doubler,f
|
119 |
|
|
MPASM 5.50 M16C5X_TST.ASM 6-22-2013 10:14:54 PAGE 3
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
LOC OBJECT CODE LINE SOURCE TEXT
|
123 |
|
|
VALUE
|
124 |
|
|
|
125 |
|
|
0064 0800 00106 RETLW 0
|
126 |
|
|
00107
|
127 |
|
|
00108 END
|
128 |
|
|
MPASM 5.50 M16C5X_TST.ASM 6-22-2013 10:14:54 PAGE 4
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
SYMBOL TABLE
|
132 |
|
|
LABEL VALUE
|
133 |
|
|
|
134 |
|
|
CountDown 00000010
|
135 |
|
|
Double 00000060
|
136 |
|
|
Doubler 00000011
|
137 |
|
|
Loop 00000056
|
138 |
|
|
OuterLoop 00000012
|
139 |
|
|
Reduce 0000005A
|
140 |
|
|
ScratchPadRam 00000010
|
141 |
|
|
Start 00000050
|
142 |
|
|
__16F59 00000001
|
143 |
|
|
__DEBUG 1
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
MEMORY USAGE MAP ('X' = Used, '-' = Unused)
|
147 |
|
|
|
148 |
|
|
0040 : ---------------- XXXXXXXXXXXXXXXX XXXXX----------- ----------------
|
149 |
|
|
07C0 : ---------------- ---------------- ---------------- ---------------X
|
150 |
|
|
|
151 |
|
|
All other memory blocks unused.
|
152 |
|
|
|
153 |
|
|
Program Memory Words Used: 22
|
154 |
|
|
Program Memory Words Free: 2026
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
Errors : 0
|
158 |
|
|
Warnings : 0 reported, 0 suppressed
|
159 |
|
|
Messages : 1 reported, 0 suppressed
|
160 |
|
|
|
161 |
|
|
|