📄 dualdptr.lst
字号:
DUALDPTR PAGE 1
1 ;********************************************************************
2 ;
3 ; Author : ADI - Apps www.analog.com/MicroConverter
4 ;
5 ; Date : July 2003
6 ;
7 ; File : DualDPTR.asm
8 ;
9 ; Hardware : ADuC845
10 ;
11 ; Description : Sample Program to show the new ADuC845 features
12 ; of dual DPTRs. In Aspire debugger select Program
13 ; Memory and External Memory from the Debug View Bar.
14 ; Under Run -> Select Uploadable Areas and under
15 ; External Memory type 0-200 and click OK. This enables
16 ; real time uploading of these locations from this memory
17 ; area into the debugger.
18 ; NOTE: Several lines of this program will have to be
19 ; disabled, most notably the UART configuration section
20 ; due to the use of the UART debugger.
21 ;********************************************************************
22
23 $MOD845 ; Use ADuC845 predefined symbols
00B4 24 LED EQU P3.4 ; P3.4 drives red LED on eval board
25
26 ;____________________________________________________________________
27 ; BEGINNING OF CODE
---- 28 CSEG
29
0000 30 ORG 0000h
31 ; highest speed
0000 75D700 32 MOV PLLCON, #0 ;Disable PLLCON write when using debugger
33
34 ; CONFIGURE UART....
35
0003 759E86 36 MOV T3CON,#86h ;Will need to disable UART configuration
0006 759D12 37 MOV T3FD,#12h ;when using debugger as any writes to UART
0009 759852 38 MOV SCON,#52h ;timing or config registers could affect
39 ;the debugger interface
40 ; enable the intenal On-Chip XRAM
41
000C 75AF01 42 MOV CFG845, #01h
43
44 ; move 512 bytes from code memory (adress 1000h -> 1200h) into
45 ; data XRAM (address 0000h -> 0200h)
46 ; configure the datapointer
000F 900000 47 MOV DPTR, #0
0012 75A755 48 MOV DPCON, #55h ; auto toggle between DPTRs
49 ; auto increment shadow DPTR
50 ; auto increment main DPTR
51 ; select shadow DPTR
0015 901000 52 MOV DPTR, #1000h
53
0018 54 COPYDATALOOP:
55 ; read Code Memory using Shadow DPTR
0018 E4 56 CLR A
0019 93 57 MOVC A, @A+DPTR ; read code memory
58 ; auto increment shadow DPTR
DUALDPTR PAGE 2
59 ; swap to main DPTR
60 ; write to XRAM using main DPTR
001A F0 61 MOVX @DPTR, A ; write to XRAM
62 ; auto increment main DPTR
63 ; swap to shadow DPTR
64 ; check if at end of loop
65 ; NOTE: shadow DPTR selected (not main)
001B E583 66 MOV A, DPH
001D B412F8 67 CJNE A, #12h, COPYDATALOOP
68
69
0020 00 70 NOP ; <----NOTE: Set a breakpoint in the debugger here
71 ; This will show that the values in code memory
72 ; at addresses 1000h thru 1200h has been mapped
73 ; into XRAM at address 0000h thru 0200h.
74 ; The debugger will not run the nextpiece of
75 ; code as this requires the use of the serial port
76
77
78
79
80 ; transmit XRAM up UART
0021 75A704 81 MOV DPCON, #4 ; select main DPTR
82 ; auto increment DPTR
83 ; do not toggle DPTR
0024 900000 84 MOV DPTR, #0
0027 7810 85 MOV R0, #16
0029 86 SENDXRAM:
0029 E0 87 MOVX A, @DPTR
002A 120042 88 CALL SENDVAL
002D D8FA 89 DJNZ R0, SENDXRAM
90 ; send a newline
002F 740A 91 MOV A, #10
0031 120058 92 CALL SENDCHAR
0034 740D 93 MOV A, #13
0036 120058 94 CALL SENDCHAR
0039 7810 95 MOV R0, #16
003B E583 96 MOV A, DPH
003D B402E9 97 CJNE A, #2, SENDXRAM
98
0040 80FE 99 JMP $
100
101
102 ;____________________________________________________________________
103 ; SENDVAL
104
0042 105 SENDVAL: ; converts the hex value of A into two ASCII chars,
106 ; and then spits these two characters up the UART.
107 ; does not change the value of A.
108
0042 C0E0 109 PUSH ACC
0044 C4 110 SWAP A
0045 120060 111 CALL HEX2ASCII
0048 120058 112 CALL SENDCHAR ; send high nibble
004B D0E0 113 POP ACC
004D C0E0 114 PUSH ACC
004F 120060 115 CALL HEX2ASCII
0052 120058 116 CALL SENDCHAR ; send low nibble
DUALDPTR PAGE 3
0055 D0E0 117 POP ACC
118
0057 22 119 RET
120 ;____________________________________________________________________
121 ; SENDCHAR
122
0058 123 SENDCHAR: ; sends ASCII value contained in A to UART
124
0058 3099FD 125 JNB TI,$ ; wait til present char gone
005B C299 126 CLR TI ; must clear TI
005D F599 127 MOV SBUF,A
128
005F 22 129 RET
130 ;____________________________________________________________________
131 ; HEX2ASCII
132
0060 133 HEX2ASCII: ; converts A into the hex character representing the
134 ; value of A's least significant nibble
135
0060 540F 136 ANL A,#00Fh
0062 B40A00 137 CJNE A,#00Ah,$+3
0065 4002 138 JC IO0030
0067 2407 139 ADD A,#007h
0069 2430 140 IO0030: ADD A,#'0'
141
006B 22 142 RET
143 ;____________________________________________________________________
1000 144 ORG 1000h
145
1000 00010203 146 DB 00h,01h,02h,03h,04h,05h,06h,07h,08h,09h,0Ah,0Bh,0Ch,0Dh,0Eh,0Fh
1004 04050607
1008 08090A0B
100C 0C0D0E0F
1010 10111213 147 DB 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1Ah,1Bh,1Ch,1Dh,1Eh,1Fh
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -