• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

BASIC compiler/interpreter for PIC32MX/MZ-80K


Commit MetaInfo

Revisiona8f2a2fb367957f62d9732be551206575fe1d26f (tree)
Zeit2019-04-07 08:07:34
AutorKatsumi <kmorimatsu@sour...>
CommiterKatsumi

Log Message

Avoid exception when interrupt in case using $s5 in function.

Ändern Zusammenfassung

Diff

--- a/mips/zoea/debug.c
+++ b/mips/zoea/debug.c
@@ -275,18 +275,19 @@ static const void* debugjumptable[]={
275275
276276 int _debug_test(int a0, int a1, int a2, int a3, int param4, int param5){
277277 asm volatile(".set noreorder");
278- asm volatile("b label1");
279- asm volatile("lui $v1,0x1234");
280- asm volatile("ori $v1,$v1,0x5678");
281- asm volatile("sw $v0,0($v1)");
282- asm volatile("label1:");
283- asm volatile("sw $zero,0x1234($v1)");
284- asm volatile("sw $zero,0x1234($gp)");
285278 asm volatile("nop");
286- int i;
287- for2(i,1,10){
288- asm volatile("nop");
289- }
279+ asm volatile("nop");
280+ asm volatile("nop");
281+ asm volatile("nop");
282+ asm volatile("nop");
283+ asm volatile("nop");
284+ asm volatile("nop");
285+ asm volatile("nop");
286+ asm volatile("nop");
287+ asm volatile("nop");
288+ asm volatile("nop");
289+ asm volatile("nop");
290+ a2&=0xFFFFFFFC;
290291 return a2+a3;
291292 }
292293
--- a/mips/zoea/exception.c
+++ b/mips/zoea/exception.c
@@ -44,7 +44,12 @@ void dumpMemory(){
4444 void dumpMemory(){}
4545 #endif //ifdef DUMPFILE
4646
47+void _general_exception_handler_main (void);
4748 void _general_exception_handler (void){
49+ asm volatile("la $sp,%0"::"i"(&RAM[RAMSIZE-4]));
50+ asm volatile("j _general_exception_handler_main");
51+}
52+void _general_exception_handler_main (void){
4853 int i;
4954 // $v1 is g_ex_data
5055 asm volatile("la $v1,%0"::"i"(&g_ex_data[0]));
@@ -79,7 +84,9 @@ void _general_exception_handler (void){
7984 if((readbuttons()&(KEYUP|KEYDOWN|KEYLEFT|KEYRIGHT|KEYSTART|KEYFIRE))
8085 !=(KEYUP|KEYDOWN|KEYLEFT|KEYRIGHT|KEYSTART|KEYFIRE)) i=0;
8186 }
82- asm volatile("j SoftReset");
87+ RCONbits.POR=0;
88+ RCONbits.EXTR=0;
89+ asm volatile("j 0x9FC00000");
8390 #endif
8491 }
8592
--- a/mips/zoea/timer.c
+++ b/mips/zoea/timer.c
@@ -167,14 +167,30 @@ char* timer_function(){
167167 */
168168
169169 void BasicInt(int addr){
170- // $a0 is the address in BASIC code
170+ // Note that $s0-$s7 values must be set again here.
171171 asm volatile(".set noreorder");
172+ // Set s5 for initial_s5_stack
173+ asm volatile("la $s5,%0"::"i"(&g_initial_s5_stack[2]));
174+ // Set s7 for easy calling call_library()
175+ asm volatile("la $s7,%0"::"i"(&call_library));
176+ // $a0 is the address in BASIC code
172177 asm volatile("jr $a0");
173178 asm volatile("nop");
174179 }
175180 #pragma interrupt CS1Handler IPL1SOFT vector 2
176181 void CS1Handler(void){
177182 int i;
183+ // Store s0-s7, fp, and ra in stacks
184+ asm volatile("#":::"s0");
185+ asm volatile("#":::"s1");
186+ asm volatile("#":::"s2");
187+ asm volatile("#":::"s3");
188+ asm volatile("#":::"s4");
189+ asm volatile("#":::"s5");
190+ asm volatile("#":::"s6");
191+ asm volatile("#":::"s7");
192+ asm volatile("#":::"fp");
193+ asm volatile("#":::"ra");
178194 while(g_interrupt_flags){
179195 for(i=0;i<NUM_INTERRUPT_TYPES;i++){
180196 if (g_interrupt_flags & (1<<i)) {