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

Subversion Repositories m16c5x

[/] [m16c5x/] [trunk/] [Code/] [MPLAB/] [M16C5x_Tst.ASM] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 MichaelA
;**************************************************************************
2
; M16C5x_Tst.ASM
3
;
4
; This sample program runs on most all PIC devices.  To ensure
5
; proper execution, replace the processor specified in the LIST directive
6
; with your target processor.
7
;
8
; Program execution starts at location H'50'.  The loop routine executes
9
; seven times.  The routines Reduce and Double execute one time for each
10
; loop.
11
;
12
; After the loop executes seven times, the program repeats execution from
13
; the beginning.
14
;
15
;
16
; Variable    Initial    Description
17
;              Value
18
;--------------------------------------------------------------------------
19
; CountDown     255      Decreases to 128 by subtracting Doubler
20
; Doubler        1       Increases to 128 by adding to itself
21
; OuterLoop      7       Decrements by one to 0
22
;
23
;
24
; The program generates the following values:
25
;
26
; Cycle #    CountDown   Doubler     OuterLoop
27
;   0           255           1           7
28
;   1           254           2           6
29
;   2           252           4           5
30
;   3           248           8           4
31
;   4           240          16           3
32
;   5           224          32           2
33
;   6           192          64           1
34
;   7           128         128           0
35
;
36
;**************************************************************************
37
 
38
        LIST P=16F59, R=DEC
39
 
40
;--------------------------------------------------------------------------
41
;   Set ScratchPadRam here.  If you are using a PIC16C5X device, use:
42
;ScratchPadRam EQU     0x10
43
;   Otherwise, use:
44
;ScratchPadRam EQU     0x20
45
;--------------------------------------------------------------------------
46
 
47
ScratchPadRam   EQU     0x10
48
 
49
;--------------------------------------------------------------------------
50
; Variables
51
;--------------------------------------------------------------------------
52
 
53
CountDown       EQU     ScratchPadRam+0
54
Doubler         EQU     ScratchPadRam+1
55
OuterLoop       EQU     ScratchPadRam+2
56
 
57
 
58
;--------------------------------------------------------------------------
59
; Program Code
60
;--------------------------------------------------------------------------
61
;--------------------------------------------------------------------------
62
;   Set the reset vector here.  If you are using a PIC16C5X device, use:
63
;               ORG     
64
;   Otherwise, use:
65
;               ORG     0
66
;--------------------------------------------------------------------------
67
 
68
                ORG     H'7FF'
69
                GOTO    Start
70
 
71
;--------------------------------------------------------------------------
72
; Main Program
73
;--------------------------------------------------------------------------
74
 
75
                ORG     H'50'
76
 
77
Start
78
                MOVLW   255             ;   Initialize the variables to
79
                MOVWF   CountDown       ; their starting values.
80
                MOVLW   1
81
                MOVWF   Doubler
82
                MOVLW   7
83
                MOVWF   OuterLoop
84
Loop
85
                CALL    Reduce          ;   Perform the inner portion of
86
                DECFSZ  OuterLoop,f     ; the loop.
87
                GOTO    Loop
88
 
89
                GOTO    Start           ;   Repeat the whole thing.
90
 
91
;--------------------------------------------------------------------------
92
Reduce
93
                SWAPF   Doubler,f       ;   Reduce CountDown by the
94
                SWAPF   Doubler,w       ; value of Doubler.  Then
95
                SWAPF   Doubler,f       ; call the doubling routine.
96
                SUBWF   CountDown,f
97
                CALL    Double
98
                RETLW   0
99
 
100
;--------------------------------------------------------------------------
101
Double
102
                SWAPF   Doubler,f       ;   Double the value of Doubler
103
                SWAPF   Doubler,w       ; by adding it to itself.
104
                SWAPF   Doubler,f
105
                ADDWF   Doubler,f
106
                RETLW   0
107
 
108
                END
109
 

powered by: WebSVN 2.1.0

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