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

📄 startup.a51

📁 UPSD单片机的LCD显示器汉字驱动程序
💻 A51
📖 第 1 页 / 共 2 页
字号:
; 5.  Initialize the INTERNAL data memory spaces.
; First we do the internal memory space.  It must always be initialized, for
; all chips, and all memory models.  Internal memory will be initialized with
; whatever value is set into A.  Zero is recommended, although other values
; could be used for special debugging reasons.
;
; Note:  This initialization counts DOWN.

IF IDATALEN <> 0
   CLR   A
   MOV   R0, #LOW(IDATALEN - 1)

__INTERNAL_MEM_INIT__:
   MOV   @R0, A
   DJNZ  R0, __INTERNAL_MEM_INIT__
ENDIF

;-------------------------------------------------------------------------------
; 6.  Initialize the EXTERNAL data memory spaces.
; We initialize the XDATA memory counting up from XDATASTART.  Note that
; PDATA is the same location as XDATA.
;
; (** For 751 use **) CUT FROM HERE ---------- vvvvvvv  ----------
; Either EXPLICITLY do not use XDATA in your code, or comment out or remove
; the entire XDATA initialization section to make absolutely sure it is NOT used.
;
; Note:  This initialization counts UP.
;
IF XDATALEN <> 0
   MOV   DPTR, #XDATASTART    ; set to lowest address, start there
   MOV   R1, #LOW(XDATALEN)   ; get the low byte of the length

 IF (LOW (XDATALEN)) <> 0
   MOV   R0, #(HIGH XDATALEN) + 1   ; add one for physical -> logical value
 ELSE
   MOV   R0, #HIGH (XDATALEN)       ; if 0, then it doesn't matter
 ENDIF

   CLR   A                 ; or use a special value for debugging purposes

FILLXD:
   MOVX  @DPTR, A          ; write the value contained in A through DPTR
   INC   DPTR              ; point to the next higher byte location
   DJNZ  R1, FILLXD        ; loop until filled, fall through to outer loop on 0
   PET_THE_DOG             ; if needed, put the watch dog service routine here
   DJNZ  R0,FILLXD         ;
ENDIF


;-------------------------------------------------------------------------------
; 7.  Initialization of all global and static variables.

IF INIDATA <> 0
EXTRN   CODE (?C_INITSEGSTART)      ; Data used to initialize.

 IF XSTACK <> 0
  EXTRN   XDATA (_XSTK0)
 ENDIF

F1 BIT   0D1h                       ; F1 bit of PSW definition.

   MOV   DPTR, #?C_INITSEGSTART     ; Base address.

__PAQ__:
   ;------------------------------
   ; Read identification byte (nb)
   ;------------------------------
   CLR   A
   MOVC  A, @A+DPTR
   JNZ   __INIDATA_LABEL__          ; Zero is the end of the initialization.

$IF( INTERNAL_XRAM_LIKE_8xC592 )
   MOV   P2, #0FFH
$ELSE
 $IF( XSTACK )
   MOV   P2, #HIGH(_XSTK0)
 $ENDIF
$ENDIF

   SJMP  __END_OF_INIT__

__INIDATA_LABEL__:
   ;---------------------------------------------------------
   ; LSB indicates internal memory (0) or external memory (1)
   ;---------------------------------------------------------
   CLR   C
   RRC   A
   MOV   F0, C
   ;---------------------------------------------------------------------
   ; Bit 1 indicates full zero init (1) or init with different values (0)
   ;---------------------------------------------------------------------
   CLR   C
   RRC   A
   MOV   F1, C
   ;------------------------------------------------------
   ; The others bits indicate the number of bytes to read
   ;------------------------------------------------------
   MOV   R7, A
   INC   DPTR
   CLR   A
   MOVC  A, @A+DPTR        ; Read low byte of address to initialize.
   MOV   R0, A
   ANL   C, /F0            ; Verify if it is not a bit initialization.
   JC    __BIT_INIT__
   JNB   F0, __INIT_LOOP__
   CLR   A
   INC   DPTR
   MOVC  A, @A+DPTR        ; Read high byte of address to initialize.

$IF( INTERNAL_XRAM_LIKE_8xC592 )
   MOV   B, A
$ELSE
   MOV   P2, A
$ENDIF

__INIT_LOOP__:
   ;------------------------------
   ; Initialization of memory area
   ;------------------------------
   CLR   A
   JB    F1, __ZERO_INIT__
   INC   DPTR
   MOVC  A, @A+DPTR           ; Read initialization value

__ZERO_INIT__:
   JB    F0, __XDATA_INIT__

   MOV   @R0, A
   INC   R0

__SIZE_LOOP__:
   DJNZ  R7, __INIT_LOOP__

__SIZE_LOOP_1__:
   INC   DPTR
   SJMP  __PAQ__

__XDATA_INIT__:
$IF( INTERNAL_XRAM_LIKE_8xC592 )
   XCH   A, DPH
   XCH   A, B
   XCH   A, DPH
   XCH   A, DPL
   XCH   A, R0
   XCH   A, DPL
   MOVX  @DPTR, A
   INC   DPTR
   XCH   A, DPH
   XCH   A, B
   XCH   A, DPH
   XCH   A, DPL
   XCH   A, R0
   XCH   A, DPL
$ELSE
   MOVX  @R0, A
   INC   R0
   CJNE  R0, #0, __SIZE_LOOP__
   INC   P2
$ENDIF
   SJMP  __SIZE_LOOP__

__BIT_INIT__:
   MOV   A, R0
   RR    A
   RR    A
   RR    A
   ANL   A, #1Fh
   ADD   A, #20h
   MOV   R1, A           ; Byte address
   MOV   A, R0
   ANL   A, #7h          ; Bit offset
   MOV   R0, A
   CLR   A
   SETB  C
   RLC   A
   CJNE  R0, #00, __MASK_GEN__
   SJMP  __MASK_APPLY__

   ;---------------------------------------------
   ; Generate mask to initialize the correct bit
   ;---------------------------------------------
__MASK_GEN__:
   RLC   A
   DJNZ  R0, __MASK_GEN__

   ;------------------------------------------
   ; Initialize the correct bit with the mask
   ;------------------------------------------
__MASK_APPLY__:
   ORL   A, @R1
   MOV   @R1, A
   SJMP  __SIZE_LOOP_1__

__END_OF_INIT__:

ENDIF


;-------------------------------------------------------------------------------
; 8.  If selected, initialize the chips I/O registers.  This applies to all
; chips and all memory models.  You can save a few bytes by eliminating
; this code for some applications.

IF INITIO <> 0
   MOV   TMOD, #20H
   MOV   TCON, #40H
   MOV   SCON, #52H
   MOV   TH1, #low(TIM1_INIT)
ENDIF


;-------------------------------------------------------------------------------
; 9.  If selected, initialize the external stack.
; Note:  (** For 751 use **) Do not use this section the 751 processors.
IF XSTACK <> 0
EXTRN DATA  ( SPX )
EXTRN XDATA (_XSTK0)
XSTACKLEN   SET   0100h    ; an initial length for the external stack
   MOV   SPX, #low(_XSTK0)-1
ENDIF
	MOV     HPD_ADDR, #_INITP2?      ;SC030313 MOV     P2, #_INITP2?

; (** For 751 use **) CUT TO HERE ---------- ^^^^^^^ ----------


   LJMP  main     ;  (** For 751 use **) changed the LJMP to an AJMP

   END            ; End of module

;===============================================================================
;                               STARTUP.A51
;===============================================================================

⌨️ 快捷键说明

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