BASIC compiler/interpreter for PIC32MX/MZ-80K
Revisión | 34af68baeeaaf193851454f318db9988e2f28047 (tree) |
---|---|
Tiempo | 2019-03-24 10:43:49 |
Autor | Katsumi <kmorimatsu@sour...> |
Commiter | Katsumi |
OPTION NOLINENUM in Zoea
@@ -160,8 +160,10 @@ char* compile_line(void){ | ||
160 | 160 | printstr(resolve_label(g_line)); |
161 | 161 | return ERR_MULTIPLE_LABEL; |
162 | 162 | } |
163 | - check_obj_space(1); | |
164 | - g_object[g_objpos++]=0x34160000|g_line; //ori s6,zero,xxxx; | |
163 | + if (!g_nolinenum) { | |
164 | + check_obj_space(1); | |
165 | + g_object[g_objpos++]=0x34160000|g_line; //ori s6,zero,xxxx; | |
166 | + } | |
165 | 167 | } |
166 | 168 | while(g_source[g_srcpos]!=0x0D && g_source[g_srcpos]!=0x0A){ |
167 | 169 | err=statement(); |
@@ -213,6 +213,7 @@ extern int g_var_mem[ALLOC_BLOCK_NUM]; | ||
213 | 213 | extern unsigned short g_var_pointer[ALLOC_BLOCK_NUM]; |
214 | 214 | extern unsigned short g_var_size[ALLOC_BLOCK_NUM]; |
215 | 215 | extern char g_temp_area_used; |
216 | +extern char g_nolinenum; | |
216 | 217 | extern int* g_heap_mem; |
217 | 218 | extern int g_max_mem; |
218 | 219 | extern char g_disable_break; |
@@ -228,13 +228,13 @@ static const char initext[]= | ||
228 | 228 | "#PRINT\n"; |
229 | 229 | |
230 | 230 | static const char bastext[]= |
231 | -"print getdir$()\n" | |
232 | -"end\n" | |
233 | -"\n" | |
234 | -"\n" | |
235 | -"\n" | |
231 | +"REM 1\n" | |
232 | +"REM 2\n" | |
233 | +"REM 3\n" | |
236 | 234 | "\n" |
235 | +"CLS\n" | |
237 | 236 | "\n" |
237 | +"LABEL TST:PRINT\n" | |
238 | 238 | "\n"; |
239 | 239 | |
240 | 240 | static const char class1text[]= |
@@ -122,7 +122,10 @@ int compile_and_link_file(char* buff,char* appname){ | ||
122 | 122 | printchar('\n'); |
123 | 123 | return -1; |
124 | 124 | } |
125 | - | |
125 | + | |
126 | + // Option initialization(s) | |
127 | + g_nolinenum=0; | |
128 | + | |
126 | 129 | // Compile the file |
127 | 130 | err=compile_file(); |
128 | 131 | close_file(); |
@@ -55,6 +55,9 @@ unsigned short g_var_size[ALLOC_BLOCK_NUM]; | ||
55 | 55 | // Flag to use temporary area when compiling |
56 | 56 | char g_temp_area_used; |
57 | 57 | |
58 | +// Flag to use option nolinenum | |
59 | +char g_nolinenum; | |
60 | + | |
58 | 61 | // Heap area |
59 | 62 | int* g_heap_mem; |
60 | 63 | int g_max_mem; |
@@ -105,6 +105,8 @@ LABEL xxx | ||
105 | 105 | 代入する。「LET」は省略可。 |
106 | 106 | MUSIC x$ |
107 | 107 | BGMを演奏する。詳細は、下記<MUSIC>の項を参照。 |
108 | +OPTION x[,y[,z ... ]]] | |
109 | + 各種オプションを指定する。オプションについては、下記<オプション>の項を参照。 | |
108 | 110 | PLAYWAVE x$[,y] |
109 | 111 | 音楽用のWAVEファイル(ファイル名をx$で指定)を演奏する。WAVEのフォーマットは、 |
110 | 112 | モノラル、ビット長は8、サンプリング周波数が15700 Hzの物を指定する。16000 Hz |
@@ -619,6 +621,16 @@ SYSTEM(105) | ||
619 | 621 | SYSTEM 200,x |
620 | 622 | ディスプレイの表示を停止(xが0のとき)、もしくは開始(xが0以外の時)する。 |
621 | 623 | |
624 | +<オプション> | |
625 | +OPTIONステートメントを使って、コンパイル時もしくは実行時に色々なオプションを指定 | |
626 | +する事が可能です。次のオプションが有ります。 | |
627 | + | |
628 | +OPTION NOLINENUM | |
629 | + コンパイル時に、行番号を指定する命令を挿入しない。このオプションにより、プロ | |
630 | + グラムサイズを小さくして実行速度を増加する効果が見込める。ただし、エラーが発 | |
631 | + 生した場合に、どの行でのエラーかは分からなくなる。また、一時領域を使うような | |
632 | + 場合(主に文字列操作)は、該当箇所にLABELステートメントを入れること。 | |
633 | + | |
622 | 634 | <クラス・オブジェクト関連機能> |
623 | 635 | |
624 | 636 | クラスとオブジェクトの利用方法について、詳しくはclass.txtを参照して下さい。 |
@@ -110,6 +110,7 @@ var namearray=[ | ||
110 | 110 | 'NEXT', |
111 | 111 | 'NEW', |
112 | 112 | 'NOT', |
113 | + 'OPTION', | |
113 | 114 | 'PCG', |
114 | 115 | 'PEEK', |
115 | 116 | 'PEEK16', |
@@ -1550,6 +1550,24 @@ char* setdir_statement(){ | ||
1550 | 1550 | return 0; |
1551 | 1551 | } |
1552 | 1552 | |
1553 | +char* option_statement(){ | |
1554 | + while(1){ | |
1555 | + next_position(); | |
1556 | + if (nextCodeIs("NOLINENUM")) { | |
1557 | + g_nolinenum=1; | |
1558 | + } else { | |
1559 | + return ERR_SYNTAX; | |
1560 | + } | |
1561 | + next_position(); | |
1562 | + if (g_source[g_srcpos]==',') { | |
1563 | + g_srcpos++; | |
1564 | + } else { | |
1565 | + break; | |
1566 | + } | |
1567 | + } | |
1568 | + return 0; | |
1569 | +} | |
1570 | + | |
1553 | 1571 | #ifdef __DEBUG |
1554 | 1572 | char* debug_statement(){ |
1555 | 1573 | call_lib_code(LIB_DEBUG); |
@@ -1698,6 +1716,7 @@ static const void* statement_list[]={ | ||
1698 | 1716 | "CALL ",call_statement, |
1699 | 1717 | "STATIC ",static_statement, |
1700 | 1718 | "SETDIR ",setdir_statement, |
1719 | + "OPTION ",option_statement, | |
1701 | 1720 | // List of additional statements follows |
1702 | 1721 | ADDITIONAL_STATEMENTS |
1703 | 1722 | }; |
@@ -91,6 +91,7 @@ static const int reserved_var_names[]={ | ||
91 | 91 | 0x000b4321, /*NEXT*/ |
92 | 92 | 0x000148f8, /*NEW*/ |
93 | 93 | 0x00014a5d, /*NOT*/ |
94 | + 0x38a658d7, /*OPTION*/ | |
94 | 95 | 0x000152c0, /*PCG*/ |
95 | 96 | 0x000cacec, /*PEEK*/ |
96 | 97 | 0x3b1c6aea, /*PEEK16*/ |