⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 l51ibank.a51

📁 Keil uVision2
💻 A51
📖 第 1 页 / 共 2 页
字号:
$NOMOD51 NOLINES
$NOCOND
;------------------------------------------------------------------------------
;  This file is part of the LX51 Banked Linker/Locater package
;  Copyright (c) 1988 - 2004 Keil Elektronik GmbH and Keil Software, Inc.
;  Version 1.00 (Code and Variable Banking for Mentor M8051EW based devices)
;------------------------------------------------------------------------------
;
;  This file implements code and variable banking for Mentor M8051EW based
;  devices, which offer three memory extension registers MEX1, MEX2 and MEX3.
;  *** Important Notes ***  
;
;  1.  Full support for Mentor M8051EW based devices requires the LX51 linker/
;      locater.  This file does not work with the BL51 linker/locater.
;
;  2.  The C51 Compiler must be invoked with the directive VARBANKING(1)
;      in order to use this file.   It is unimportant if you are using 
;      variable banking (far memory type) in your application.
;
;  3.  This file contains also the CPU startup code
;  
;  4.  You need to use the C51 run-time library files C51M*.LIB.
;
;************************ Configuration Section *******************************
?B_NBANKS       EQU  4    ; Define maximum Number of Banks                    *
;                         ; following values are allowed: 2 .. 16             *
;                                                                             *
?B_CB           EQU  3    ; Define Memory Bank used for constants             *
;                         ; following values are allowed: 0 .. 7              *
;                         ; The value 0xFF uses the current program code bank *
;                         ; as constant bank                                  *
;                                                                             *
?B_VAR_BANKING  EQU  1    ; XDATA Variable Banking (far memory type support)  *
;                         ; 0 XDATA Variable Banking no required              *
;                         ; 1 XDATA Variable Banking uses this L51IBANK.A51   *
;                         ;   module                                          *
; Notes: ?B_VAR_BANKING uses the C51 'far' memory type to extent the space    *
;        for variables in RAM space of the M8051EW device.                    *
;                                                                            *
;******************************************************************************
;------------------------- CPU STARTUP CONFIGURATION --------------------------
;
;  User-defined Power-On Initialization of Memory
;
;  With the following EQU statements the initialization of memory
;  at processor reset can be defined:
;
;               ; the absolute start-address of IDATA memory is always 0
IDATALEN        EQU     80H     ; the length of IDATA memory in bytes.
;
XDATASTART      EQU     0H      ; the absolute start-address of XDATA memory
XDATALEN        EQU     0H      ; the length of XDATA memory in bytes.
;
PDATASTART      EQU     0H      ; the absolute start-address of PDATA memory
PDATALEN        EQU     0H      ; the length of PDATA memory in bytes.
;
;  Notes:  The IDATA space overlaps physically the DATA and BIT areas of the
;          8051 CPU. At minimum the memory space occupied from the C51 
;          run-time routines must be set to zero.
;------------------------------------------------------------------------------
;
;  Reentrant Stack Initilization
;
;  The following EQU statements define the stack pointer for reentrant
;  functions and initialized it:
;
;  Stack Space for reentrant functions in the SMALL model.
IBPSTACK        EQU     0       ; set to 1 if small reentrant is used.
IBPSTACKTOP     EQU     0FFH+1  ; set top of stack to highest location+1.
;
;  Stack Space for reentrant functions in the LARGE model.      
XBPSTACK        EQU     0       ; set to 1 if large reentrant is used.
XBPSTACKTOP     EQU     0FFFFH+1; set top of stack to highest location+1.
;
;  Stack Space for reentrant functions in the COMPACT model.    
PBPSTACK        EQU     0       ; set to 1 if compact reentrant is used.
PBPSTACKTOP     EQU     0FFFFH+1; set top of stack to highest location+1.
;
;------------------------------------------------------------------------------
;
;  Page Definition for Using the Compact Model with 64 KByte xdata RAM
;
;  The following EQU statements define the xdata page used for pdata
;  variables. The EQU PPAGE must conform with the PPAGE control used
;  in the linker invocation.
;
PPAGEENABLE     EQU     0       ; set to 1 if pdata object are used.
;
PPAGE           EQU     0       ; define PPAGE number.
;
PPAGE_SFR       DATA    0A0H    ; SFR that supplies uppermost address byte
;               (most 8051 variants use P2 as uppermost address byte)
;
;------------------------------------------------------------------------------

                NAME    ?BANK?SWITCHING


;******************************************************************************
;                                                                             *
; THEORY OF OPERATION                                                         *
; -------------------                                                         *
; The section below describes the code generated by LX51.  LX51 generates for *
; each function that is located in a code memory bank and called from the     *
; common area or a different code bank and entry into the INTRABANK CALL      *
; TABLE.  The INTRABANK CALL TABLE is located in the SEGMENT ?BANK?SELECT and *
; listed in the Linker MAP file. The entries in that TABLE have the following *
; format:                                                                     *
;                                                                             *
;   ?FCT?1:  MOV  MEX1,#n          ; Load bank number of target FCT           *
;            LJMP FCT              ; Jump to Target Code                      *
;                                                                             *
; Instead of directly calling the function FCT, the Linker changes the entry  *
; to ?FCT?1.  This entry selects the bank where the function FCT is located   *
; and jumps to that function.                                                 *
;******************************************************************************

; Standard SFR Symbols 
ACC       DATA    0E0H
B         DATA    0F0H
SP        DATA    81H
DPL       DATA    82H
DPH       DATA    83H


; Definitions for Mentor Memory Extension Hardware
MEX1      DATA    94H
MEX2      DATA    95H
MEX3      DATA    96H
MEXSP     DATA    97H
PUBLIC ?C?DPSEL
?C?DPSEL  DATA    0A2H

?B_MODE         EQU     8        ; 8 for Mentor EW8051 integrated MEX Banking
?B_RST_BANK     EQU     0        ; active code bank after CPU reset
?B_IB           EQU     0        ; use Bank 0 for Interrupt Functions
?B_CURRENTBANK  EQU     MEX1     ; MEX1.4 .. 7 hold current code bank
?B_FACTOR       EQU     4        ; ?B_CURRENTBANK shift factor
?B_MASK         EQU     0F0H     ; valid bits in ?B_CURRENTBANK
?B_MEX1         EQU     MEX1     ; address of next bank register

                PUBLIC  ?B_NBANKS, ?B_MODE
                PUBLIC  ?B_CURRENTBANK
                PUBLIC  ?B_FACTOR, ?B_RST_BANK
                PUBLIC  ?B_IB, ?B_CB, ?B_MEX1


?C_C51STARTUP   SEGMENT   CODE
?STACK          SEGMENT   IDATA

                RSEG    ?STACK
                DS      1

                EXTRN CODE (?C_START)
                PUBLIC  ?C_STARTUP

                CSEG    AT      0
?C_STARTUP:     LJMP    STARTUP1

                RSEG    ?C_C51STARTUP

STARTUP1:

IF IDATALEN <> 0
                MOV     R0,#IDATALEN - 1
                CLR     A
IDATALOOP:      MOV     @R0,A
                DJNZ    R0,IDATALOOP
ENDIF

IF XDATALEN <> 0
                MOV     DPTR,#XDATASTART
                MOV     R7,#LOW (XDATALEN)
  IF (LOW (XDATALEN)) <> 0
                MOV     R6,#(HIGH (XDATALEN)) +1
  ELSE
                MOV     R6,#HIGH (XDATALEN)
  ENDIF
                CLR     A
XDATALOOP:      MOVX    @DPTR,A
                INC     DPTR
                DJNZ    R7,XDATALOOP
                DJNZ    R6,XDATALOOP
ENDIF

IF PPAGEENABLE <> 0
                MOV     PPAGE_SFR,#PPAGE
ENDIF

IF PDATALEN <> 0
                MOV     R0,#LOW (PDATASTART)
                MOV     R7,#LOW (PDATALEN)
                CLR     A
PDATALOOP:      MOVX    @R0,A
                INC     R0
                DJNZ    R7,PDATALOOP
ENDIF

IF IBPSTACK <> 0
EXTRN DATA (?C_IBP)

                MOV     ?C_IBP,#LOW IBPSTACKTOP
ENDIF

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -