STARTUP.A51
上传用户:cnlazy
上传日期:2021-04-25
资源大小:163k
文件大小:4k
源码类别:

单片机开发

开发平台:

DOS

  1. $NOMOD51
  2. ;------------------------------------------------------------------------------
  3. ;  This file is part of the C51 Compiler package
  4. ;  Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
  5. ;------------------------------------------------------------------------------
  6. ;  STARTUP.A51:  This code is executed after processor reset.
  7. ;
  8. ;  To translate this file use A51 with the following invocation:
  9. ;
  10. ;     A51 STARTUP.A51
  11. ;
  12. ;  To link the modified STARTUP.OBJ file to your application use the following
  13. ;  BL51 invocation:
  14. ;
  15. ;     BL51 <your object file list>, STARTUP.OBJ <controls>
  16. ;
  17. ;------------------------------------------------------------------------------
  18. ;
  19. ;  User-defined Power-On Initialization of Memory
  20. ;
  21. ;  With the following EQU statements the initialization of memory
  22. ;  at processor reset can be defined:
  23. ;
  24. ; ; the absolute start-address of IDATA memory is always 0
  25. IDATALEN EQU 80H ; the length of IDATA memory in bytes.
  26. ;
  27. XDATASTART EQU 0H ; the absolute start-address of XDATA memory
  28. XDATALEN EQU 0H ; the length of XDATA memory in bytes.
  29. ;
  30. PDATASTART EQU 0H ; the absolute start-address of PDATA memory
  31. PDATALEN EQU 0H ; the length of PDATA memory in bytes.
  32. ;
  33. ;  Notes:  The IDATA space overlaps physically the DATA and BIT areas of the
  34. ;          8051 CPU. At minimum the memory space occupied from the C51 
  35. ;          run-time routines must be set to zero.
  36. ;------------------------------------------------------------------------------
  37. ;
  38. ;  Reentrant Stack Initilization
  39. ;
  40. ;  The following EQU statements define the stack pointer for reentrant
  41. ;  functions and initialized it:
  42. ;
  43. ;  Stack Space for reentrant functions in the SMALL model.
  44. IBPSTACK EQU 0 ; set to 1 if small reentrant is used.
  45. IBPSTACKTOP EQU 0FFH+1 ; set top of stack to highest location+1.
  46. ;
  47. ;  Stack Space for reentrant functions in the LARGE model.
  48. XBPSTACK EQU 0 ; set to 1 if large reentrant is used.
  49. XBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1.
  50. ;
  51. ;  Stack Space for reentrant functions in the COMPACT model.
  52. PBPSTACK EQU 0 ; set to 1 if compact reentrant is used.
  53. PBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1.
  54. ;
  55. ;------------------------------------------------------------------------------
  56. ;
  57. ;  Page Definition for Using the Compact Model with 64 KByte xdata RAM
  58. ;
  59. ;  The following EQU statements define the xdata page used for pdata
  60. ;  variables. The EQU PPAGE must conform with the PPAGE control used
  61. ;  in the linker invocation.
  62. ;
  63. PPAGEENABLE EQU 0 ; set to 1 if pdata object are used.
  64. PPAGE EQU 0 ; define PPAGE number.
  65. ;
  66. ;------------------------------------------------------------------------------
  67. ; Standard SFR Symbols 
  68. ACC     DATA    0E0H
  69. B       DATA    0F0H
  70. SP      DATA    81H
  71. DPL     DATA    82H
  72. DPH     DATA    83H
  73. NAME ?C_STARTUP
  74. ?C_C51STARTUP SEGMENT   CODE
  75. ?STACK SEGMENT   IDATA
  76. RSEG ?STACK
  77. DS 1
  78. EXTRN CODE (?C_START)
  79. PUBLIC ?C_STARTUP
  80. CSEG AT 0
  81. ?C_STARTUP: LJMP STARTUP1
  82. RSEG ?C_C51STARTUP
  83. STARTUP1:
  84. IF IDATALEN <> 0
  85. MOV R0,#IDATALEN - 1
  86. CLR A
  87. IDATALOOP: MOV @R0,A
  88. DJNZ R0,IDATALOOP
  89. ENDIF
  90. IF XDATALEN <> 0
  91. MOV DPTR,#XDATASTART
  92. MOV R7,#LOW (XDATALEN)
  93.   IF (LOW (XDATALEN)) <> 0
  94. MOV R6,#(HIGH (XDATALEN)) +1
  95.   ELSE
  96. MOV R6,#HIGH (XDATALEN)
  97.   ENDIF
  98. CLR A
  99. XDATALOOP: MOVX @DPTR,A
  100. INC DPTR
  101. DJNZ R7,XDATALOOP
  102. DJNZ R6,XDATALOOP
  103. ENDIF
  104. IF PPAGEENABLE <> 0
  105. MOV P2,#PPAGE
  106. ENDIF
  107. IF PDATALEN <> 0
  108. MOV R0,#PDATASTART
  109. MOV R7,#LOW (PDATALEN)
  110. CLR A
  111. PDATALOOP: MOVX @R0,A
  112. INC R0
  113. DJNZ R7,PDATALOOP
  114. ENDIF
  115. IF IBPSTACK <> 0
  116. EXTRN DATA (?C_IBP)
  117. MOV ?C_IBP,#LOW IBPSTACKTOP
  118. ENDIF
  119. IF XBPSTACK <> 0
  120. EXTRN DATA (?C_XBP)
  121. MOV ?C_XBP,#HIGH XBPSTACKTOP
  122. MOV ?C_XBP+1,#LOW XBPSTACKTOP
  123. ENDIF
  124. IF PBPSTACK <> 0
  125. EXTRN DATA (?C_PBP)
  126. MOV ?C_PBP,#LOW PBPSTACKTOP
  127. ENDIF
  128. MOV SP,#?STACK-1
  129. ; This code is required if you use L51_BANK.A51 with Banking Mode 4
  130. ; EXTRN CODE (?B_SWITCH0)
  131. ;               CALL    ?B_SWITCH0      ; init bank mechanism to code bank 0
  132. LJMP ?C_START
  133. END