• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No 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

Revisãoa1ee537c7d3b88c5d262424a379540a6e961ec82 (tree)
Hora2019-04-08 10:00:46
AutorKatsumi <kmorimatsu@sour...>
CommiterKatsumi

Mensagem de Log

Force TMR1=0 when executing TIMER statement

Mudança Sumário

Diff

--- a/mips/megalopa/compiler.c
+++ b/mips/megalopa/compiler.c
@@ -24,15 +24,17 @@
2424 $s7: address of call_library()
2525 $t8-$t9: used as temporary registors
2626 $k0-$k1: not used
27- $gp: for accessing global valiables by C
27+ $gp: for accessing global variables by C
2828 $sp: stack pointer
29- $fp($s8) for accessing valiables by BASIC
29+ $fp($s8) for accessing variables by BASIC
3030 $ra: contains return address
3131 */
3232
3333 #include "compiler.h"
3434
3535 void start_program(void* addr, void* memory){
36+ // Note that if usage of $s0-$s7, and $fp is changed,
37+ // revice BasicInt() in timer.c, too.
3638 static unsigned int stored_sp;
3739 // Store s0-s7, fp, and ra in stacks
3840 asm volatile("#":::"s0");
--- a/mips/megalopa/timer.c
+++ b/mips/megalopa/timer.c
@@ -139,21 +139,22 @@ char* timer_statement(){
139139 char* err;
140140 err=get_value();
141141 if (err) return err;
142- i=(int)(&g_timer);
143- check_obj_space(3);
142+ i=(int)(&g_timer)+0x8000;
143+ check_obj_space(4);
144144 g_object[g_objpos++]=0x3C030000|((i>>16)&0x0000FFFF); // lui v1,xxxx
145- g_object[g_objpos++]=0x34630000|(i&0x0000FFFF); // ori v1,v1,xxxx
146- g_object[g_objpos++]=0xAC620000; // sw v0,0(v1)
145+ g_object[g_objpos++]=0xAC620000|((i-0x8000)&0xFFFF); // sw v0,xxxx(v1)
146+ i=(int)(&TMR1)+0x8000;//0xBF800610
147+ g_object[g_objpos++]=0x3C030000|((i>>16)&0x0000FFFF); // lui v1,0xbf80
148+ g_object[g_objpos++]=0xAC600000|((i-0x8000)&0xFFFF); // sw zero,0x0610(v1)
147149 return 0;
148150 }
149151
150152 char* timer_function(){
151153 int i;
152- i=(int)(&g_timer);
153- check_obj_space(3);
154+ i=(int)(&g_timer)+0x8000;
155+ check_obj_space(2);
154156 g_object[g_objpos++]=0x3C020000|((i>>16)&0x0000FFFF); // lui v0,xxxx
155- g_object[g_objpos++]=0x34420000|(i&0x0000FFFF); // ori v0,v0,xxxx
156- g_object[g_objpos++]=0x8C420000; // lw v0,0(v0)
157+ g_object[g_objpos++]=0x8C420000|((i-0x8000)&0xFFFF); // lw v0,xxxx(v0)
157158 return 0;
158159 }
159160
@@ -165,16 +166,15 @@ char* timer_function(){
165166
166167 */
167168
168-void BasicInt(int addr){
169- // Note that $s0-$s7 values must be set again here.
170- asm volatile(".set noreorder");
169+void BasicInt(int addr,void* memory){
170+ // Note that $s0-$s7 and $fp values must be set again here.
171171 // Set s5 for initial_s5_stack
172172 asm volatile("la $s5,%0"::"i"(&g_initial_s5_stack[2]));
173173 // Set s7 for easy calling call_library()
174174 asm volatile("la $s7,%0"::"i"(&call_library));
175- // $a0 is the address in BASIC code
175+ // Set fp and execute BASIC code at $a0
176+ asm volatile("addu $fp,$zero,$a1");
176177 asm volatile("jr $a0");
177- asm volatile("nop");
178178 }
179179 #pragma interrupt CS1Handler IPL1SOFT vector 2
180180 void CS1Handler(void){
@@ -193,7 +193,7 @@ void CS1Handler(void){
193193 while(g_interrupt_flags){
194194 for(i=0;i<NUM_INTERRUPT_TYPES;i++){
195195 if (g_interrupt_flags & (1<<i)) {
196- if (g_int_vector[i]) BasicInt(g_int_vector[i]);
196+ if (g_int_vector[i]) BasicInt(g_int_vector[i],(void*)(&g_var_mem[0]));
197197 g_interrupt_flags &= (1<<i)^0xffff;
198198 }
199199 }
--- a/mips/zoea/compiler.c
+++ b/mips/zoea/compiler.c
@@ -24,15 +24,17 @@
2424 $s7: address of call_library()
2525 $t8-$t9: used as temporary registors
2626 $k0-$k1: not used
27- $gp: for accessing global valiables by C
27+ $gp: for accessing global variables by C
2828 $sp: stack pointer
29- $fp($s8) for accessing valiables by BASIC
29+ $fp($s8) for accessing variables by BASIC
3030 $ra: contains return address
3131 */
3232
3333 #include "compiler.h"
3434
3535 void start_program(void* addr, void* memory){
36+ // Note that if usage of $s0-$s7, and $fp is changed,
37+ // revice BasicInt() in timer.c, too.
3638 static unsigned int stored_sp;
3739 // Store s0-s7, fp, and ra in stacks
3840 asm volatile("#":::"s0");
--- a/mips/zoea/timer.c
+++ b/mips/zoea/timer.c
@@ -139,21 +139,22 @@ char* timer_statement(){
139139 char* err;
140140 err=get_value();
141141 if (err) return err;
142- i=(int)(&g_timer);
143- check_obj_space(3);
142+ i=(int)(&g_timer)+0x8000;
143+ check_obj_space(4);
144144 g_object[g_objpos++]=0x3C030000|((i>>16)&0x0000FFFF); // lui v1,xxxx
145- g_object[g_objpos++]=0x34630000|(i&0x0000FFFF); // ori v1,v1,xxxx
146- g_object[g_objpos++]=0xAC620000; // sw v0,0(v1)
145+ g_object[g_objpos++]=0xAC620000|((i-0x8000)&0xFFFF); // sw v0,xxxx(v1)
146+ i=(int)(&TMR1)+0x8000;//0xBF800610
147+ g_object[g_objpos++]=0x3C030000|((i>>16)&0x0000FFFF); // lui v1,0xbf80
148+ g_object[g_objpos++]=0xAC600000|((i-0x8000)&0xFFFF); // sw zero,0x0610(v1)
147149 return 0;
148150 }
149151
150152 char* timer_function(){
151153 int i;
152- i=(int)(&g_timer);
153- check_obj_space(3);
154+ i=(int)(&g_timer)+0x8000;
155+ check_obj_space(2);
154156 g_object[g_objpos++]=0x3C020000|((i>>16)&0x0000FFFF); // lui v0,xxxx
155- g_object[g_objpos++]=0x34420000|(i&0x0000FFFF); // ori v0,v0,xxxx
156- g_object[g_objpos++]=0x8C420000; // lw v0,0(v0)
157+ g_object[g_objpos++]=0x8C420000|((i-0x8000)&0xFFFF); // lw v0,xxxx(v0)
157158 return 0;
158159 }
159160
@@ -165,16 +166,15 @@ char* timer_function(){
165166
166167 */
167168
168-void BasicInt(int addr){
169- // Note that $s0-$s7 values must be set again here.
170- asm volatile(".set noreorder");
169+void BasicInt(int addr,void* memory){
170+ // Note that $s0-$s7 and $fp values must be set again here.
171171 // Set s5 for initial_s5_stack
172172 asm volatile("la $s5,%0"::"i"(&g_initial_s5_stack[2]));
173173 // Set s7 for easy calling call_library()
174174 asm volatile("la $s7,%0"::"i"(&call_library));
175- // $a0 is the address in BASIC code
175+ // Set fp and execute BASIC code at $a0
176+ asm volatile("addu $fp,$zero,$a1");
176177 asm volatile("jr $a0");
177- asm volatile("nop");
178178 }
179179 #pragma interrupt CS1Handler IPL1SOFT vector 2
180180 void CS1Handler(void){
@@ -193,7 +193,7 @@ void CS1Handler(void){
193193 while(g_interrupt_flags){
194194 for(i=0;i<NUM_INTERRUPT_TYPES;i++){
195195 if (g_interrupt_flags & (1<<i)) {
196- if (g_int_vector[i]) BasicInt(g_int_vector[i]);
196+ if (g_int_vector[i]) BasicInt(g_int_vector[i],(void*)(&g_var_mem[0]));
197197 g_interrupt_flags &= (1<<i)^0xffff;
198198 }
199199 }