📄 l51_bank.lst
字号:
A51 MACRO ASSEMBLER L51_BANK 11/17/2005 23:11:35 PAGE 1
MACRO ASSEMBLER A51 V7.10
OBJECT MODULE PLACED IN L51_BANK.OBJ
ASSEMBLER INVOKED BY: D:\Keil\C51\BIN\A51.EXE L51_BANK.A51 NOMOD51 SET(SMALL) DEBUG XREF EP
LOC OBJ LINE SOURCE
1 $nomod51 NOLINES
2 $nocond
3 ;------------------------------------------------------------------------------
4 ; This file is part of the BL51 / LX51 Banked Linker/Locater package
5 ; Copyright (c) 1988 - 2001 Keil Elektronik GmbH and Keil Software, Inc.
6 ; Version 2.21 (Code and Variable Banking for Classic 8051 Derivatives)
7 ;------------------------------------------------------------------------------
8 ;************************ Configuration Section *******************************
0002 9 ?B_NBANKS EQU 2 ; Define maximum Number of Banks *
10 ; ; following values are allowed: 2, 4, 8, 16, 32, 64 *
11 ; ; for BL51 the maximum value for ?B_BANKS is 32 *
12 ; ; for LX51 the maximum value for ?B_BANKS is 64 *
13 ; *
0004 14 ?B_MODE EQU 4 ; 0 for Bank-Switching via 8051 Port *
15 ; ; 1 for Bank-Switching via XDATA Port *
16 ; ; 4 for user-provided bank switch code *
17 ; *
0000 18 ?B_RTX EQU 0 ; 0 for applications without real-time OS *
19 ; ; 1 for applications using the RTX-51 real-time OS *
20 ; *
0000 21 ?B_VAR_BANKING EQU 0 ; Variable Banking via L51_BANK (far memory support)*
22 ; ; 0 Variable Banking does not use L51_BANK.A51 *
23 ; ; 1 Variable Banking uses this L51_BANK.A51 module *
24 ; Notes: ?B_VAR_BANKING uses the 'far' and 'far const' C51 memory types to *
25 ; extent the space for variables in RAM and/or ROM of classic 8051 *
26 ; device. The same hardware as for code banking is used. Program *
27 ; code banking and variable banking share the same hardware I/O pins. *
28 ; The C51 Compiler must be used with the VARBANKING directive. *
29 ; Variable Banking is only supported with the LX51 linker/locater. *
30 ; *
00FF 31 ?B_RST_BANK EQU 0xFF ; specifies the active code bank number after CPU *
32 ; ; Reset. Used to reduce the entries in the *
33 ; ; INTERBANK CALL TABLE. The value 0xFF disables *
34 ; ; this LX51 linker/locater optimization. *
35 ; Note: Interbank Call Table optimization is only possible with LX51. *
36 ; *
37 ;-----------------------------------------------------------------------------*
38 ; *
ENDIF; *
50 ; *
ENDIF; *
59 ; *
60 IF ?B_MODE = 4; *
61 ;-----------------------------------------------------------------------------*
62 ; if ?BANK?MODE is 4 define the following switch macros *
63 ; For bank switching via user-provided bank switch code you must define for *
64 ; each memory bank a own macro which contains the bank switch code. The *
65 ; following example shows how to use the I/O lines P1.4 and P1.7 for bank *
66 ; switching. Since you can select just 4 banks with two address lines, just *
67 ; four macros are defined. The number of macros must conform with the number *
68 ; ?B_NBANKS number, i.e. for an application with 16 memory banks you must *
69 ; define 16 macros. *
70 ; *
71 ; IMPORTANT NOTES: *
72 ; 1. The bank switch logic must be initialized before using it. Therefore *
73 ; add the following lines of code at the end of the STARTUP.A51 file: *
74 ; : *
75 ; EXTRN CODE (?B_SWITCH0) *
A51 MACRO ASSEMBLER L51_BANK 11/17/2005 23:11:35 PAGE 2
76 ; CALL ?B_SWITCH0 ; init bank mechanism to code bank 0 *
77 ; LJMP ?C_START ; line already exits at the end of file *
78 ; : *
79 ; *
80 ; 2. If the bank switch macros and the additional control code generate more *
81 ; than 256 bytes, you need to set the LONG_MACRO flag below. The error *
82 ; message "BANK SWITCH CODE BIGGER THAN 256 BYTES, SET LONG_MACRO TO 1" *
83 ; is generated in case that this is required. *
84 ; *
85 ; 3. The only registers that can be modified in this routines without prior *
86 ; saving are: DPTR and ACC. *
87 ; *
88 ; *
0000 89 LONG_MACRO EQU 0 ; 0 default, for normal macros and up to 8 banks *
90 ; ; 1 big macro code or many banks *
91 ; *
92 ; *
0090 93 P1 DATA 90H ; I/O Port Addresses *
00B0 94 P3 DATA 0B0H ; *
00B1 95 SFCF DATA 0B1H
96 ; *
97 SWITCH0 MACRO ; Switch to Memory Bank #0 *
98 ORL SFCF, #001H
99 ENDM ; *
100 ; *
101 SWITCH1 MACRO ; Switch to Memory Bank #1 *
102 ANL SFCF, #0FEH
103 ENDM ; *
104 ; *
105 ;-----------------------------------------------------------------------------*
106 ENDIF; *
107 ; *
ENDIF; *
128 ; *
129 ;******************************************************************************
130 ; *
131 ; THEORY OF OPERATION *
132 ; ------------------- *
133 ; The section below describes the code generated by BL51 or LX51 and the *
134 ; operation of the L51_BANK.A51 module. BL51/LX51 generates for each *
135 ; function that is located in a code memory bank and called from the common *
136 ; area or a different code bank and entry into the INTRABANK CALL TABLE. The *
137 ; INTRABANK CALL TABLE is located in the SEGMENT ?BANK?SELECT and listed in *
138 ; the Linker MAP file. The entries in that TABLE have the following format: *
139 ; *
140 ; ?FCT?1: MOV DPTR,#FCT ; Load Address of target FCT *
141 ; JMP ?B_BANKn ; Switch to Bank and Jump to Target Code *
142 ; *
143 ; Instead of directly calling the function FCT, the Linker changes the entry *
144 ; to ?FCT?1. This entry selects the bank where the function FCT is located *
145 ; and calls that function via the routines defined in this L51_BANK.A51 file. *
146 ; The L51_BANK.A51 file contains two sets of functions for each bank: *
147 ; *
148 ; ?B_BANKn is a routine which saves the entry of the ?B_SWITCHn function *
149 ; for the current active bank on the STACK and switches to the *
150 ; bank 'n'. Then it jumps to the address specified by the DPTR *
151 ; register. It is allowed to modify the following registers in *
152 ; the ?B_BANKn routine: A, B, R0, DPTR, PSW *
153 ; *
154 ; ?B_SWITCHn is a function which selects the bank 'n'. This function is *
155 ; used at the end of a user function to return to the calling *
156 ; code bank. Only the following registers may be altered in the *
157 ; ?B_SWITCHn function: R0, DPTR *
158 ; *
159 ; The current active bank is stored in ?B_CURRENTBANK. RTX-51 uses this *
160 ; variable to restore the code bank after a task switch. To get correct *
A51 MACRO ASSEMBLER L51_BANK 11/17/2005 23:11:35 PAGE 3
161 ; results, ?B_CURRENTBANK must be set to the code bank before the hardware *
162 ; switch is done, or the code banking sequences must be interrupt protected. *
163 ;******************************************************************************
164
165 NAME ?BANK?SWITCHING
166
167 PUBLIC ?B_NBANKS, ?B_MODE, ?B_CURRENTBANK, ?B_MASK
168 PUBLIC ?B_FACTOR, ?B_RST_BANK
ENDIF
172
173 ; Standard SFR Symbols required in L51_BANK.A51
00E0 174 ACC DATA 0E0H
00F0 175 B DATA 0F0H
0082 176 DPL DATA 82H
0083 177 DPH DATA 83H
00A8 178 IE DATA 0A8H
00AF 179 EA BIT IE.7
180
181
182 ; generate Mask and Bank Number Information
183 IF ?B_NBANKS <= 2
0001 184 MASK EQU 00000001B
ENDIF
196
ENDIF ; close block IF ?B_MODE = 0 *******************************************
444
445
ENDIF ; close block IF ?B_MODE = 1 *******************************************
687
688
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -