1 ##################################################################
3 # AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4 # DATE CREATED: 1/12/02
6 # PROJECT: Plasma CPU core
7 # COPYRIGHT: Software placed into the public domain by the author.
8 # Software 'as is' without warranty. Author liable for nothing.
10 # Initializes the stack pointer and jumps to main().
11 ##################################################################
12 #Reserve 512 bytes for stack
22 #These four instructions should be the first instructions.
23 #convert.exe previously initialized $gp, .sbss_start, .bss_end, $sp
24 la $gp, _gp #initialize global pointer
25 la $5, __bss_start #$5 = .sbss_start
26 la $4, _end #$2 = .bss_end
27 la $sp, InitStack+488 #initialize stack pointer
43 ###################################################
45 .global interrupt_service_routine
46 .ent interrupt_service_routine
47 interrupt_service_routine:
51 #Registers $26 and $27 are reserved for the OS
52 #Save all temporary registers
53 #Slots 0($29) through 12($29) reserved for saving a0-a3
54 addi $29, $29, -104 #adjust sp
73 mfc0 $26, $14 #C0_EPC=14 (Exception PC)
74 addi $26, $26, -4 #Backup one opcode
82 lw $4, 0x20($6) #IRQ_STATUS
83 lw $6, 0x10($6) #IRQ_MASK
85 jal OS_InterruptServiceRoutine
88 #Restore all temporary registers
112 addi $29, $29, 104 #adjust sp
115 ori $27, $0, 0x1 #re-enable interrupts
117 mtc0 $27, $12 #STATUS=1; enable interrupts
119 .end interrupt_service_routine
123 ###################################################
124 .global OS_AsmInterruptEnable
125 .ent OS_AsmInterruptEnable
126 OS_AsmInterruptEnable:
130 mtc0 $4, $12 #STATUS=1; enable interrupts
133 .end OS_AsmInterruptEnable
136 ###################################################
137 .global OS_AsmInterruptInit
138 .ent OS_AsmInterruptInit
141 #Patch interrupt vector to 0x1000003c
142 la $5, OS_AsmPatchValue
154 #Registers $26 and $27 are reserved for the OS
155 #Code to place at address 0x3c
162 .end OS_AsmInterruptInit
165 ###################################################
189 ###################################################
213 ###################################################
228 ###################################################