• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

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

Révisionaeac15e5789baa88885c81631ead80c1d20b0893 (tree)
l'heure2019-04-01 09:53:54
AuteurKatsumi <kmorimatsu@sour...>
CommiterKatsumi

Message de Log

Interface directory in Zoea source file

Change Summary

Modification

--- a/mips/zoea/api.h
+++ b/mips/zoea/api.h
@@ -32,7 +32,7 @@
3232 // Used for asm("wait")
3333 #define WAIT "wait"
3434
35-#include "videoout.h"
36-#include "SDFSIO.h"
37-#include "ps2keyboard.h"
35+#include "interface/videoout.h"
36+#include "interface/SDFSIO.h"
37+#include "interface/ps2keyboard.h"
3838 #include "debug.h"
--- a/mips/zoea/basic.mcp
+++ b/mips/zoea/basic.mcp
@@ -170,37 +170,37 @@ file_004=file.c
170170 file_005=float.c
171171 file_006=function.c
172172 file_007=globalvars.c
173-file_008=keyinput.c
174-file_009=library.c
175-file_010=linker.c
176-file_011=main.c
177-file_012=memory.c
178-file_013=music.c
179-file_014=operator.c
180-file_015=run.c
181-file_016=statement.c
182-file_017=string.c
183-file_018=value.c
184-file_019=debug.c
185-file_020=cmpdata.c
186-file_021=varname.c
187-file_022=envspecific.c
188-file_023=class.c
189-file_024=args.c
190-file_025=timer.c
173+file_008=library.c
174+file_009=linker.c
175+file_010=main.c
176+file_011=memory.c
177+file_012=music.c
178+file_013=operator.c
179+file_014=run.c
180+file_015=statement.c
181+file_016=string.c
182+file_017=value.c
183+file_018=debug.c
184+file_019=cmpdata.c
185+file_020=varname.c
186+file_021=envspecific.c
187+file_022=class.c
188+file_023=args.c
189+file_024=timer.c
190+file_025=interface\keyinput.c
191191 file_026=api.h
192192 file_027=compiler.h
193193 file_028=editor.h
194-file_029=keyinput.h
195-file_030=main.h
196-file_031=ps2keyboard.h
197-file_032=SDFSIO.h
198-file_033=videoout.h
199-file_034=debug.h
200-file_035=envspecific.h
201-file_036=lib_videoout_machikania.X.a
202-file_037=libsdfsio.a
203-file_038=ps2keyboard.X.a
194+file_029=main.h
195+file_030=debug.h
196+file_031=envspecific.h
197+file_032=interface\keyinput.h
198+file_033=interface\ps2keyboard.h
199+file_034=interface\SDFSIO.h
200+file_035=interface\videoout.h
201+file_036=interface\lib_videoout_machikania.X.a
202+file_037=interface\libsdfsio.a
203+file_038=interface\ps2keyboard.X.a
204204 file_039=App_32MX170F256B.ld
205205 file_040=help.txt
206206 file_041=MACHIKAN.INI
--- a/mips/zoea/class.c
+++ b/mips/zoea/class.c
@@ -157,7 +157,8 @@ char* resolve_unresolved(int class){
157157 break;
158158 default:
159159 return ERR_UNKNOWN;
160- } }
160+ }
161+ }
161162 return 0;
162163 }
163164
@@ -194,6 +195,15 @@ char* update_class_info(int class){
194195 cstruct[z+1]: public method pointer
195196 */
196197
198+/*
199+ Object structure:
200+ object[0]: pointer to class structure
201+ object[1]: field value
202+ ...
203+ object[n]: field value
204+ (according to class structure; public field(s) first, then private field(s))
205+*/
206+
197207 char* construct_class_structure(int class){
198208 int* record;
199209 int i;
--- a/mips/zoea/compiler.h
+++ b/mips/zoea/compiler.h
@@ -482,6 +482,19 @@ char* interrupt_statement();
482482 #define ASM_LW_A0_XXXX_S8 0x8FC40000
483483 #define ASM_LW_A0_XXXX_S5 0x8EA40000
484484
485+// Interrupt macros
486+// 16 different type interruptions are possible
487+#define NUM_INTERRUPT_TYPES 1
488+#define INTERRUPT_TIMER 0
489+extern short g_interrupt_flags;
490+extern int g_int_vector[NUM_INTERRUPT_TYPES];
491+#define raise_interrupt_flag(x) do {\
492+ if (g_int_vector[x]) {\
493+ IFS0bits.CS1IF=1;\
494+ g_interrupt_flags|=(1<<(x));\
495+ }\
496+} while(0)
497+
485498 // Division macro for unsigned long
486499 // Valid for 31 bits for all cases and 32 bits for some cases
487500 #define div32(x,y,z) ((((unsigned long long)((unsigned long)(x)))*((unsigned long long)((unsigned long)(y))))>>(z))
--- a/mips/zoea/debug.c
+++ b/mips/zoea/debug.c
@@ -228,12 +228,14 @@ static const char initext[]=
228228 "#PRINT\n";
229229
230230 static const char bastext[]=
231-"USETIMER 600\n"
232-"INTERRUPT TIMER,LABEL1\n"
233-"END\n"
234-"LABEL LABEL1\n"
235-"RETURN\n"
231+"I=1:WHILE I<=10\n"
232+"I=I+1:WEND\n"
236233 "\n"
234+"I=1:DO\n"
235+"I=I+1:LOOP UNTIL I=11\n"
236+"\n"
237+"FOR I=1 TO 10\n"
238+"NEXT\n"
237239 "\n"
238240 "\n"
239241 "\n";
@@ -269,6 +271,8 @@ static const void* debugjumptable[]={
269271 FSfopen,
270272 };
271273
274+#define for2(x,y,z) for(x=y;x<=z;x++)
275+
272276 int _debug_test(int a0, int a1, int a2, int a3, int param4, int param5){
273277 asm volatile(".set noreorder");
274278 asm volatile("b label1");
@@ -279,6 +283,10 @@ int _debug_test(int a0, int a1, int a2, int a3, int param4, int param5){
279283 asm volatile("nop");
280284 asm volatile("nop");
281285 asm volatile("nop");
286+ int i;
287+ for2(i,1,10){
288+ asm volatile("nop");
289+ }
282290 return a2+a3;
283291 }
284292
--- a/mips/zoea/editor.c
+++ b/mips/zoea/editor.c
@@ -4,14 +4,10 @@
44 http://www.ze.em-net.ne.jp/~kenken/index.html
55 */
66
7-/*
8- This file is shared by Megalopa and Zoea
9-*/
10-
117 #include <xc.h>
128 #include "api.h"
139 #include "editor.h"
14-#include "keyinput.h"
10+#include "interface/keyinput.h"
1511 #include "compiler.h"
1612 #include "main.h"
1713
--- a/mips/zoea/envspecific.c
+++ b/mips/zoea/envspecific.c
@@ -8,8 +8,7 @@
88 #include <xc.h>
99 #include "main.h"
1010 #include "compiler.h"
11-#include "videoout.h"
12-#include "ps2keyboard.h"
11+#include "api.h"
1312
1413 /*
1514 int readbuttons();
--- a/mips/zoea/envspecific.h
+++ b/mips/zoea/envspecific.h
@@ -5,7 +5,7 @@
55 kmorimatsu@users.sourceforge.jp
66 */
77
8-#define CPU_CLOCK_HZ 57272720
8+#define CPU_CLOCK_HZ (g_use_graphic ? 53693175 : 57272720)
99 #define PERSISTENT_RAM_SIZE (1024*52)
1010
1111 int readbuttons();
--- a/mips/zoea/function.c
+++ b/mips/zoea/function.c
@@ -157,7 +157,6 @@ char* rnd_function(){
157157 return 0;
158158 }
159159
160-
161160 char* chr_function(void){
162161 char* err;
163162 err=get_value();
--- a/mips/zoea/help.txt
+++ b/mips/zoea/help.txt
@@ -241,6 +241,23 @@ SETDIR x$
241241 エラーが有れば0以外を返す。
242242 (FEOF(), FGETC(), FINPUT$(), FLEN(), FSEEK(), GETDIR$()関数も参照のこと)
243243
244+<タイマー及び割り込み関連命令と関数>
245+USETIMER x
246+ タイマーを開始する。xはタイマーの速度を、Hzで指定(4以上の値)。
247+
248+TIMER x
249+ 現在のタイマー値を32ビット整数(x)で設定する。
250+
251+TIMER()
252+ タイマーの現在値を、32ビット整数値として返す。
253+
254+INTERRUPT xxx,yyy[,z1[,z2 ... ]]
255+ 割り込みを設定する。xxxは割り込みの種類、yyyは割り込み時のサブルーチンをラベ
256+ ルで指定。z1, z2等を指定すると、割り込み用サブルーチンの引数となる。現在使用
257+ 可能な割り込みの種類は以下の通り。
258+ TIMER
259+ タイマー割り込み。タイマー値が1増えるごとに割り込みがかかる。
260+
244261 <整数型関数>
245262 以下、x, y, zは整数値を、x$, y$, z$は文字列を指します。[ ]は省略可能である事
246263 を示します。
--- a/mips/zoea/library.c
+++ b/mips/zoea/library.c
@@ -13,7 +13,7 @@
1313 #include "main.h"
1414 #include "compiler.h"
1515 #include "api.h"
16-#include "keyinput.h"
16+#include "interface/keyinput.h"
1717 #include "stdlib.h"
1818 #include "math.h"
1919
--- a/mips/zoea/main.c
+++ b/mips/zoea/main.c
@@ -84,7 +84,7 @@
8484 #include "api.h"
8585 #include "compiler.h"
8686 #include "editor.h"
87-#include "keyinput.h"
87+#include "interface/keyinput.h"
8888 #include "main.h"
8989
9090 //外付けクリスタル with PLL (16倍)
--- a/mips/zoea/timer.c
+++ b/mips/zoea/timer.c
@@ -12,17 +12,30 @@
1212 #include <xc.h>
1313 #include "compiler.h"
1414
15-#define INTERRUPT_TIMER 1
15+/*
16+ 16 different type interruptions are possible.
17+ See definition in compiler.h like:
18+ #define NUM_INTERRUPT_TYPES 1
19+ #define INTERRUPT_TIMER 0
20+ extern short g_interrupt_flags;
21+ extern int g_int_vector[NUM_INTERRUPT_TYPES];
22+ #define raise_interrupt_flag(x) do {\
23+*/
1624
1725 // Timer value that increments every timer event
1826 static int g_timer;
1927
20-// Enable or disable interrupt
21-static char g_interrupt_enabled;
28+// Flags for interrupt
29+short g_interrupt_flags;
2230 // Jump address when interrupt
23-static int g_int_vector;
31+int g_int_vector[NUM_INTERRUPT_TYPES];
32+
33+/*
34+ Initialize and termination
35+*/
2436
2537 void init_timer(){
38+ int i;
2639 // Stop timer, first
2740 T1CON=0x0000;
2841 IEC0bits.T1IE=0;
@@ -31,7 +44,7 @@ void init_timer(){
3144 g_timer=0;
3245 // Disable interrupt
3346 IEC0bits.CS1IE=0;
34- g_interrupt_enabled=0;
47+ for(i=0;i<NUM_INTERRUPT_TYPES;i++) g_int_vector[i]=0;
3548 }
3649
3750 void stop_timer(){
@@ -40,9 +53,12 @@ void stop_timer(){
4053 IEC0bits.T1IE=0;
4154 // Disable interrupt
4255 IEC0bits.CS1IE=0;
43- g_interrupt_enabled=0;
4456 }
4557
58+/*
59+ Timer interprtation
60+*/
61+
4662 // Interrupt handler
4763 #ifndef __DEBUG
4864 // Timer1 is also used for debug mode
@@ -52,8 +68,8 @@ void T1Handler(void){
5268 g_timer++;
5369 // Clear Timer1 interrupt flag
5470 IFS0bits.T1IF=0;
55- // Raise CS1 interrupt flag if required
56- IFS0bits.CS1IF=g_interrupt_enabled;
71+ // Raise TIMER interrupt flag
72+ raise_interrupt_flag(INTERRUPT_TIMER);
5773 }
5874
5975 void lib_usetimer(int hz){
@@ -108,6 +124,7 @@ char* timer_statement(){
108124 char* err;
109125 err=get_value();
110126 if (err) return err;
127+ i=(int)(&g_timer);
111128 check_obj_space(3);
112129 g_object[g_objpos++]=0x3C030000|((i>>16)&0x0000FFFF); // lui v1,xxxx
113130 g_object[g_objpos++]=0x34630000|(i&0x0000FFFF); // ori v1,v1,xxxx
@@ -125,9 +142,15 @@ char* timer_function(){
125142 return 0;
126143 }
127144
128-//CS1 ? Core Software Interrupt 1 2 2 IFS0<2> IEC0<2> IPC0<20:18> IPC0<17:16>
145+/*
146+ Interrupt interprtation
147+ To cause interruption, use raise_interrupt_flag() macro
148+ For example,
149+ raise_interrupt_flag(INTERRUPT_TIMER);
150+
151+*/
152+
129153 void BasicInt(int addr){
130-//TODO: here
131154 // $a0 is the address in BASIC code
132155 asm volatile(".set noreorder");
133156 asm volatile("jr $a0");
@@ -135,14 +158,21 @@ void BasicInt(int addr){
135158 }
136159 #pragma interrupt CS1Handler IPL1SOFT vector 2
137160 void CS1Handler(void){
161+ int i;
162+ while(g_interrupt_flags){
163+ for(i=0;i<NUM_INTERRUPT_TYPES;i++){
164+ if (g_interrupt_flags & (1<<i)) {
165+ if (g_int_vector[i]) BasicInt(g_int_vector[i]);
166+ g_interrupt_flags &= (1<<i)^0xffff;
167+ }
168+ }
169+ }
138170 IFS0bits.CS1IF=0;
139- BasicInt(g_int_vector);
140171 }
141172
142-void _lib_interrupt(int itype, int address){
143- // Ignore itype in the first imprementation
144- g_int_vector=address;
145- g_interrupt_enabled=1;
173+void lib_interrupt_main(int itype, int address){
174+ // Set address
175+ g_int_vector[itype]=address;
146176 // CS1 interrupt: priority 1
147177 IPC0bits.CS1IP=1;
148178 IPC0bits.CS1IS=0;
@@ -150,9 +180,10 @@ void _lib_interrupt(int itype, int address){
150180 }
151181
152182 void lib_interrupt(int itype){
183+ // $ra contains the address for interrupt
153184 // $ra is 2 word before the interrupt address
154185 asm volatile("addiu $a1,$ra,8");
155- asm volatile("j _lib_interrupt");
186+ asm volatile("j lib_interrupt_main");
156187 }
157188
158189 char* interrupt_statement(){
@@ -160,21 +191,24 @@ char* interrupt_statement(){
160191 int i,opos;
161192 char* err;
162193 next_position();
163- if (nextCodeIs("TIMER")) { itype=INTERRUPT_TIMER;
194+ if (nextCodeIs("TIMER")) {
195+ itype=INTERRUPT_TIMER;
164196 } else {
165197 return ERR_SYNTAX;
166198 }
167199 // Detect ','
168200 next_position();
169- if (g_source[g_srcpos]!=',') return ERR_SYNTAX; g_srcpos++;
201+ if (g_source[g_srcpos]!=',') return ERR_SYNTAX;
202+ g_srcpos++;
170203 // Store address to call
171204 call_quicklib_code(lib_interrupt,ASM_ORI_A0_ZERO_|itype);
172- check_obj_space(2);
173- opos=g_objpos;
205+ check_obj_space(4);
206+ // Skip the region used for interrupt-calling
207+ opos=g_objpos;
174208 g_object[g_objpos++]=0x10000000; // b xxxxx
175209 g_object[g_objpos++]=0x00000000; // nop
210+ // Begin interrupt-calling region
176211 // Store $ra
177- check_obj_space(2);
178212 g_object[g_objpos++]=0x27BDFFFC; // addiu sp,sp,-4
179213 g_object[g_objpos++]=0xAFBF0004; // sw ra,4(sp)
180214 // Compile as GOSUB statement
@@ -185,7 +219,9 @@ char* interrupt_statement(){
185219 g_object[g_objpos++]=0x8FBF0004; // lw ra,4(sp)
186220 g_object[g_objpos++]=0x03E00008; // jr ra
187221 g_object[g_objpos++]=0x08320004; // addiu sp,sp,4
222+ // End interrupt-calling region
188223 // Complete B assembly
189224 g_object[opos]|=g_objpos-opos-1;
190225 return 0;
191-}
\ No newline at end of file
226+}
227+