51-STARTUP翻译

来源:互联网 发布:数据分析师考研 编辑:程序博客网 时间:2024/04/29 07:52
文档作者:电子牛
;------------------------------------------------------------------------------
;  This file is part of the C51 Compiler package
;  这个文件是C51编译器包的一部分
;  Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
;------------------------------------------------------------------------------
;  STARTUP.A51:  This code is executed after processor reset.
;  翻译:STARTUP.A51: 这个代码执行于处理器复位
;  To translate this file use A51 with the following invocation:
;  翻译:用A51汇编(转换)这个文件的指令是:
;     A51 STARTUP.A51
;
;  To link the modified STARTUP.OBJ file to your application use the following
;  BL51 invocation:
;  翻译:接着连接STARTUP.OBJ文件到你的应用中的BL51指令是:
;     BL51 <your object file list>, STARTUP.OBJ <controls>
;  翻译:BL51 <你的工程文件列表>,STARTUP.OBJ <控制参数>
;------------------------------------------------------------------------------
;
;  User-defined Power-On Initialization of Memory
;  翻译:用户定义上电要初始化的内存
;  With the following EQU statements the initialization of memory
;  at processor reset can be defined:
;  翻译:下面是用EQU语句定义了在处理器复位时对内存的初始化
;
;  the absolute start-address of IDATA memory is always 0
;  翻译:IDATA内存的绝对启始地址总为0
IDATALEN        EQU     80H     ; the length of IDATA memory in bytes.
    ;翻译:IDATA内存的字节长度
XDATASTART      EQU     0H      ; the absolute start-address of XDATA memory
    ;翻译:XDATA内存的绝对启始地址
XDATALEN        EQU     0H      ; the length of XDATA memory in bytes.
    ;翻译:XDATA内存的字节长度
;
PDATASTART      EQU     0H      ; the absolute start-address of PDATA memory
    ;翻译:PDATA内存的绝对启始地址
PDATALEN        EQU     0H      ; the length of PDATA memory in bytes.
    ;翻译:PDATA内存的字节长度
;
;  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.
;  翻译:注释:  8051 CPU的IDATA空间在物理上包含了的DATA和BIT区域。C51(库)占用了
;   最小化内存空间,运行时程序需要把它设为0
;------------------------------------------------------------------------------
;
;  Reentrant Stack Initilization
;  翻译:重入堆栈初始化
;  The following EQU statements define the stack pointer for reentrant
;  functions and initialized it:
;  翻译:下面的EQU语句定义重入函数的堆栈指针并初始化它
;  Stack Space for reentrant functions in the SMALL model.
;  翻译:SMALL模式下的重入函数的堆栈空间
IBPSTACK        EQU     0       ; set to 1 if small reentrant is used.
    ;翻译:如果再SMALL模式下使用重入则设为1
IBPSTACKTOP     EQU     0FFH+1  ; set top of stack to highest location+1.
    ;翻译:设置堆栈顶  最高位置+1
;
;  Stack Space for reentrant functions in the LARGE model.
;  翻译:LARGE模式下的重入函数的堆栈空间
XBPSTACK        EQU     0       ; set to 1 if large reentrant is used.
    ;翻译:如果再LARGE模式下使用重入则设为1
XBPSTACKTOP     EQU     0FFFFH+1; set top of stack to highest location+1.
    ;翻译:设置堆栈顶  最高位置+1
;
;  Stack Space for reentrant functions in the COMPACT model.   
;  翻译:COMPACT模式下的重入函数的堆栈空间
PBPSTACK        EQU     0       ; set to 1 if compact reentrant is used.
    ;翻译:如果再COMPACT模式下使用重入则设为1
PBPSTACKTOP     EQU     0FFFFH+1; set top of stack to highest location+1.
    ;翻译:设置堆栈顶  最高位置+1
;
;------------------------------------------------------------------------------
;
;  Page Definition for Using the Compact Model with 64 KByte xdata RAM
;  翻译:使用COMPACT模式时为64KB的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.
;  翻译:下面的EQU语句定义PDATA变量的使用了XDATA页
PPAGEENABLE     EQU     0       ; set to 1 if pdata object are used.
    ;翻译:如果使用PDATA页则设为1
;
PPAGE           EQU     0       ; define PPAGE number.
    ;翻译:定义页号
;
PPAGE_SFR       DATA    0A0H    ; SFR that supplies uppermost address byte
    ;翻译:SFR的最高地址字节
;               (most 8051 variants use P2 as uppermost address byte)
;  (翻译:大多数8051变量要用P2的最高地址字节)
;------------------------------------------------------------------------------

; Standard SFR Symbols
; 翻译:标准SFR符号
ACC     DATA    0E0H
B       DATA    0F0H
SP      DATA    81H
DPL     DATA    82H
DPH     DATA    83H

                NAME    ?C_STARTUP


?C_C51STARTUP   SEGMENT   CODE
?STACK          SEGMENT   IDATA

                RSEG    ?STACK
                DS      1

                EXTRN CODE (?C_START)  ;外部代码(这个标号将代表用户程序的启始地址)
                PUBLIC  ?C_STARTUP  ;给外部使用的符号

                CSEG    AT      0  ;在code段的0地址处放以下代码
?C_STARTUP:     LJMP    STARTUP1

                RSEG    ?C_C51STARTUP

STARTUP1:

IF IDATALEN <> 0    ;如果长度大于1则初始化IDATA
                MOV     R0,#IDATALEN - 1
                CLR     A
IDATALOOP:      MOV     @R0,A
                DJNZ    R0,IDATALOOP
ENDIF

IF XDATALEN <> 0    ;如果长度大于1则初始化XDATA
                MOV     DPTR,#XDATASTART
                MOV     R7,#LOW (XDATALEN)
  IF (LOW (XDATALEN)) <> 0   ;预置初始化时的外循环次数到R6
                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    ;如果长度大于1则初始化PDATA
                MOV     R0,#LOW (PDATASTART)
                MOV     R7,#LOW (PDATALEN)
                CLR     A
PDATALOOP:      MOVX    @R0,A
                INC     R0
                DJNZ    R7,PDATALOOP
ENDIF

IF IBPSTACK <> 0    ;SMALL模式下使用重入函数时要设置的堆栈
EXTRN DATA (?C_IBP)

                MOV     ?C_IBP,#LOW IBPSTACKTOP
ENDIF

IF XBPSTACK <> 0    ;COMPACT模式下使用重入函数时要设置的堆栈
EXTRN DATA (?C_XBP)

                MOV     ?C_XBP,#HIGH XBPSTACKTOP
                MOV     ?C_XBP+1,#LOW XBPSTACKTOP
ENDIF

IF PBPSTACK <> 0    ;LARGE模式下使用重入函数时要设置的堆栈
EXTRN DATA (?C_PBP)
                MOV     ?C_PBP,#LOW PBPSTACKTOP
ENDIF

                MOV     SP,#?STACK-1
; This code is required if you use L51_BANK.A51 with Banking Mode 4
; 翻译:如果你的程序使用了Mode 4 程序分组技术请启动下面的程序????
; EXTRN CODE (?B_SWITCH0)
;               CALL    ?B_SWITCH0      ; init bank mechanism to code bank 0
     ;翻译:程序从第一个快开始执行
                LJMP    ?C_START ;从这里跳到你的程序入口

                END

原创粉丝点击