STARTUP.A51 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 2FFH ; 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. ;
  65. PPAGE EQU 0 ; define PPAGE number.
  66. ;
  67. PPAGE_SFR DATA 0A0H ; SFR that supplies uppermost address byte
  68. ; (most 8051 variants use P2 as uppermost address byte)
  69. ;
  70. ;------------------------------------------------------------------------------
  71. ; Standard SFR Symbols
  72. ACC DATA 0E0H
  73. B DATA 0F0H
  74. SP DATA 81H
  75. DPL DATA 82H
  76. DPH DATA 83H
  77. NAME ?C_STARTUP
  78. ?C_C51STARTUP SEGMENT CODE
  79. ?STACK SEGMENT IDATA
  80. RSEG ?STACK
  81. DS 1
  82. EXTRN CODE (?C_START)
  83. PUBLIC ?C_STARTUP
  84. CSEG AT 0
  85. ?C_STARTUP: LJMP STARTUP1
  86. RSEG ?C_C51STARTUP
  87. STARTUP1:
  88. ;Disable POR
  89. MOV 0C7H,#0AAH
  90. MOV 0C7H,#55H
  91. MOV 0FDH,#5AH
  92. MOV 0C7H,#0AAH
  93. MOV 0C7H,#55H
  94. MOV 0FDH,#0A5H
  95. IF IDATALEN <> 0
  96. MOV R0,#IDATALEN - 1
  97. CLR A
  98. IDATALOOP: MOV @R0,A
  99. DJNZ R0,IDATALOOP
  100. ENDIF
  101. IF XDATALEN <> 0
  102. MOV DPTR,#XDATASTART
  103. MOV R7,#LOW (XDATALEN)
  104. IF (LOW (XDATALEN)) <> 0
  105. MOV R6,#(HIGH (XDATALEN)) +1
  106. ELSE
  107. MOV R6,#HIGH (XDATALEN)
  108. ENDIF
  109. CLR A
  110. XDATALOOP: MOVX @DPTR,A
  111. INC DPTR
  112. DJNZ R7,XDATALOOP
  113. DJNZ R6,XDATALOOP
  114. ENDIF
  115. IF PPAGEENABLE <> 0
  116. MOV PPAGE_SFR,#PPAGE
  117. ENDIF
  118. IF PDATALEN <> 0
  119. MOV R0,#LOW (PDATASTART)
  120. MOV R7,#LOW (PDATALEN)
  121. CLR A
  122. PDATALOOP: MOVX @R0,A
  123. INC R0
  124. DJNZ R7,PDATALOOP
  125. ENDIF
  126. IF IBPSTACK <> 0
  127. EXTRN DATA (?C_IBP)
  128. MOV ?C_IBP,#LOW IBPSTACKTOP
  129. ENDIF
  130. IF XBPSTACK <> 0
  131. EXTRN DATA (?C_XBP)
  132. MOV ?C_XBP,#HIGH XBPSTACKTOP
  133. MOV ?C_XBP+1,#LOW XBPSTACKTOP
  134. ENDIF
  135. IF PBPSTACK <> 0
  136. EXTRN DATA (?C_PBP)
  137. MOV ?C_PBP,#LOW PBPSTACKTOP
  138. ENDIF
  139. MOV SP,#?STACK-1
  140. ; This code is required if you use L51_BANK.A51 with Banking Mode 4
  141. ; EXTRN CODE (?B_SWITCH0)
  142. ; CALL ?B_SWITCH0 ; init bank mechanism to code bank 0
  143. LJMP ?C_START
  144. END