📄 startup.l
字号:
00000000 00 1
00000000 00 2 #-----------------------------------------------------------------------------
00000000 00 3 #
00000000 00 4 # FILE: startup.s
00000000 00 5 #
00000000 00 6 # DESCRIPTION:
00000000 00 7 #
00000000 00 8 # This file is where the external interrupt vector definitions are for the
00000000 00 9 # external interrupt handler. It is also where the assembly part of the
00000000 00 10 # external interrupt handler is. This module also initializes vector 0x500
00000000 00 11 # for this handler. The stack frame is established here as well as zeroing
00000000 00 12 # out the .bss or uninitialized data section. The start of code execution
00000000 00 13 # starts here. Keep in mind that all assembly directives are Diab's
00000000 00 14 # assembler.
00000000 00 15 #
00000000 00 16 # REFERENCES:
00000000 00 17 #
00000000 00 18 # 1) MPC8260 Users Manual
00000000 00 19 # 2) PowerPC Microprocessor Family: The Programming Environments for
00000000 00 20 # 32-Bit Microprocessors
00000000 00 21 #
00000000 00 22 # HISTORY:
00000000 00 23 #
00000000 00 24 # 5/15/96 saw Initial Version.
00000000 00 25 # 5/24/96 saw Added Stack Layout Comment and Fixed Stack.
00000000 00 26 # 8/14/96 saw Optimized and Fixed Error with Saving
00000000 00 27 # CR on stack.
00000000 00 28 # 8/15/96 saw Space for SRR0,SRR1 on stack.
00000000 00 29 # 8/21/97 sgj Fixed register restoration bug
00000000 00 30 # 12/4/97 jay Moved startup code here from the the main source
00000000 00 31 # file. Fixed a bug where TopOfStack was not placed
00000000 00 32 # in memory where it should of. Also cleaned up what
00000000 00 33 # was asm8xx.s and is now this file.
00000000 00 34 # 8/5/98 sgj Ported to Diab
00000000 00 35 #
00000000 00 36 #-----------------------------------------------------------------------------
00000000 00 37
00000000 00 38 .file "startup.s"
00000000 00 39
00000000 00 40 #****************************************************************
00000000 00 41 #
00000000 00 42 #
00000000 00 43 #
00000000 00 44 #****************************************************************
00000000 00 45
00000000 00 46 .text
00000000 00 47 .align 2
00000000 00 48
00000000 00 49 .globl _start
00000000 00 50
00000000 00 51 _start:
00000000 00 52
00000000 00 53 #****************************************************************
00000000 00 54 #
00000000 00 55 # STACK SET-UP:
00000000 00 56 #
00000000 00 57 # If your system does not have a loader that sets up the
00000000 00 58 # application's stack before passing control to the application,
00000000 00 59 # or if the application is responsible for setting up its own
00000000 00 60 # stack, use or modify the code provided below.
00000000 00 61 #
00000000 00 62 # On most systems that allow dynamic expansion of the stack,
00000000 00 63 # stack set-up is done by the system's loader. If you have a
00000000 00 64 # system loader that sets up the stack for your application,
00000000 00 65 # comment out the code between [begin] and [end] in the
00000000 00 66 # following section.
00000000 00 67 #
00000000 00 68 # NOTE: If your system has an operating system and you
00000000 00 69 # want to return control to the operating system
00000000 00 70 # at application termination, then it is better
00000000 00 71 # to have the loader set up the application's
00000000 00 72 # stack. Otherwise, you will need to use the
00000000 00 73 # code below to save the system stack--a more
00000000 00 74 # complicated process.
00000000 00 75 #
00000000 00 76 #****************************************************************
00000000 00 77
00000000 00 78 #-------------------- set up frame stack -----------------
00000000 00 79
00000000 00 80 # allocate space for stack. Stack characteristics defined in
00000000 00 81 # linker file.
00000000 00 82
00000000 00 83 #------------------------------------------------------------------------
00000000 00 84 # SP_INIT this value is defined in tdemo.lnx which is a linker
00000000 00 85 # file.
00000000 00 86 #------------------------------------------------------------------------
00000000 00 87
00000000 00 3c20 0000 88 addis r1,r0,__SP_INIT@h
00000004 00 6021 0000 89 ori r1,r1,__SP_INIT@l
00000008 00 90
00000008 00 91 #----------------------------------------------------------------------
00000008 00 92 # load the stack pointer 72 bytes down from top of stack to ensure one
00000008 00 93 # stack frame of safety margin.
00000008 00 94 #----------------------------------------------------------------------
00000008 00 95
00000008 00 9401 ffb8 96 stwu r0,-72(r1)
0000000c 00 97
0000000c 00 98
0000000c 00 99
0000000c 00 100 #****************************************************************
0000000c 00 101 # In a real program, where the rom monitor is not being used in
0000000c 00 102 # this example, PowerPC initialization code would go here.
0000000c 00 103 #****************************************************************
0000000c 00 104
0000000c 00 105 # -->insert initialization code here
0000000c 00 106
0000000c 00 107 #****************************************************************
0000000c 00 108 #
0000000c 00 109 # jump to main()
0000000c 00 110 #
0000000c 00 111 #****************************************************************
0000000c 00 112
0000000c 00 4800 0001 113 bl Main
00000010 00 114
00000010 00 115
00000010 00 116 #****************************************************************
00000010 00 117 #
00000010 00 118 # If for what ever reason we get here, spin.
00000010 00 119 #
00000010 00 120 #****************************************************************
00000010 00 121
00000010 00 122 SPIN_HERE:
00000010 00 123
00000010 00 6000 0000 124 nop
00000014 00 4bff fffc 125 b SPIN_HERE
00000018 00 126
00000018 00 127
00000018 00 128 #*****************************************************************************
00000018 00 129 #
00000018 00 130 # ABI Stack Layout
00000018 00 131 #
00000018 00 132 # Reference: PowerPC Processor ABI Supplement 9/95
00000018 00 133 #
00000018 00 134 # Low Address
00000018 00 135 # ----------------------------------------------
00000018 00 136 # | C Frame (Quad-Word Aligned) | Word 0 <- Updated SP
00000018 00 137 # | Contents: LR, R1 (Back Chain), | Word 1
00000018 00 138 # | PADDING | Word 2
00000018 00 139 # | TOTAL: 4 Words | Word 3
00000018 00 140 # ----------------------------------------------
00000018 00 141 # | Interrupt STACK Frame (Quad-Word Aligned) | Word 0
00000018 00 142 # | Contents In Exact Order: |
00000018 00 143 # | R0-R12,SRR0,SRR1,LR,CTR,XER,CR, (19 W) |
00000018 00 144 # | PADDING (1 W) |
00000018 00 145 # | |
00000018 00 146 # | NOTE: R1,R2 Not Saved On Stack |
00000018 00 147 # | |
00000018 00 148 # | TOTAL: 20 Words | Word 19
00000018 00 149 # ----------------------------------------------
00000018 00 150 # | R1 (Back Chain) | Word 0 <- Original SP
00000018 00 151 # ----------------------------------------------
00000018 00 152 # High Address
00000018 00 153 #
00000018 00 154 #*****************************************************************************
00000018 00 155
00000018 00 156 .extern ExtIntHandler
00000018 00 157
00000018 00 158 #-----------------------------
00000018 00 159 # Globally accessible symbols
00000018 00 160 #-----------------------------
00000018 00 161
00000018 00 162 .globl ExtIntTable
00000018 00 163
00000018 00 164 #-------------------------------------------------
00000018 00 165 # PowerPC Defined Vector for External Interrupt
00000018 00 166 #-------------------------------------------------
00000018 00 167
00000018 00 168 EXTERNAL_INTERRUPT_VECTOR: .equ 0x500
00000018 00 169
00000018 00 170 #-------------------------------------------------
00000018 00 171 # ABI Compliant Interrupt StackFrame Space
00000018 00 172 #-------------------------------------------------
00000018 00 173
00000018 00 174 R0_OFFSET: .equ (0*4) # R0 Stack Offset
00000018 00 175 R1_OFFSET: .equ (1*4) # R1 Stack Offset
00000018 00 176 R2_OFFSET: .equ (2*4) # R2 Stack Offset
00000018 00 177 R3_OFFSET: .equ (3*4) # R3 Stack Offset
00000018 00 178 R4_OFFSET: .equ (4*4) # R4 Stack Offset
00000018 00 179 R5_OFFSET: .equ (5*4) # R5 Stack Offset
00000018 00 180 R6_OFFSET: .equ (6*4) # R6 Stack Offset
00000018 00 181 R7_OFFSET: .equ (7*4) # R7 Stack Offset
00000018 00 182 R8_OFFSET: .equ (8*4) # R8 Stack Offset
00000018 00 183 R9_OFFSET: .equ (9*4) # R9 Stack Offset
00000018 00 184 R10_OFFSET: .equ (10*4) # R10 Stack Offset
00000018 00 185 R11_OFFSET: .equ (11*4) # R11 Stack Offset
00000018 00 186 R12_OFFSET: .equ (12*4) # R12 Stack Offset
00000018 00 187 SRR0_OFFSET: .equ (13*4) # SRR0 Stack Offset
00000018 00 188 SRR1_OFFSET: .equ (14*4) # SRR1 Stack Offset
00000018 00 189 LR_OFFSET: .equ (15*4) # LR Stack Offset
00000018 00 190 CTR_OFFSET: .equ (16*4) # CTR Stack Offset
00000018 00 191 XER_OFFSET: .equ (17*4) # XER Stack Offset
00000018 00 192 CR_OFFSET: .equ (18*4) # CR Stack Offset
00000018 00 193 STACK_SZ: .equ (20*4) # Quad-Word Aligned Interrupt Stack Frame
00000018 00 194 C_FRAME_SZ: .equ (4*4) # Quad-Word Aligned C Frame Size
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -