BASIC compiler/interpreter for PIC32MX/MZ-80K
Revision | 8dba5357eb208a26c172292efa3c80263fba97ab (tree) |
---|---|
Zeit | 2019-01-07 12:01:47 |
Autor | Katsumi <kmorimatsu@sour...> |
Commiter | Katsumi |
POKE16, POKE32
@@ -227,19 +227,13 @@ static const char initext[]= | ||
227 | 227 | |
228 | 228 | static const char bastext[]= |
229 | 229 | "CLS\n" |
230 | -"useclass class1\n" | |
231 | -"a=new(class1)\n" | |
232 | -"a.test=1234\n" | |
233 | -"a.test2=5678\n" | |
234 | -"print gosub(LABEL1,789)\n" | |
235 | -"print a.mtest(123,456)\n" | |
236 | -"call a.mtest(321,654)\n" | |
237 | -"print hex$(a),a.test,a.test2,a.test3\n" | |
238 | -"end \n" | |
239 | -"label LABEL1\n" | |
240 | -"print ARGS(0),ARGS(1),\n" | |
241 | -"return 100\n" | |
242 | -"\n" | |
230 | +"dim a(0)\n" | |
231 | +"poke a,0x12\n" | |
232 | +"print hex$(a(0))\n" | |
233 | +"poke16 a+2,0x1234\n" | |
234 | +"print hex$(a(0))\n" | |
235 | +"poke32 a,0x12345678\n" | |
236 | +"print hex$(a(0))\n" | |
243 | 237 | "\n"; |
244 | 238 | |
245 | 239 |
@@ -271,6 +265,14 @@ int _debug_test(int a0, int a1, int a2, int a3, int param4, int param5){ | ||
271 | 265 | asm volatile("addiu $s5,$sp,4"); |
272 | 266 | asm volatile("sw $zero,4($s8)"); |
273 | 267 | asm volatile("lw $a0,4($s8)"); |
268 | + asm volatile("addiu $v0,$s8,4"); | |
269 | + asm volatile("sh $v0,0($v1)"); | |
270 | + asm volatile("sw $v0,0($v1)"); | |
271 | + ((unsigned short*)a0)[0]=(unsigned short)a1; | |
272 | + asm volatile("nop"); | |
273 | + asm volatile("nop"); | |
274 | + asm volatile("nop"); | |
275 | + asm volatile("nop"); | |
274 | 276 | asm volatile("nop"); |
275 | 277 | asm volatile("nop"); |
276 | 278 | return a2+a3; |
@@ -45,6 +45,7 @@ var namearray=[ | ||
45 | 45 | 'ATAN', |
46 | 46 | 'ATAN2', |
47 | 47 | 'BREAK', |
48 | + 'CALL', | |
48 | 49 | 'CDATA', |
49 | 50 | 'CEIL', |
50 | 51 | 'CHR', |
@@ -58,6 +59,7 @@ var namearray=[ | ||
58 | 59 | 'CURSOR', |
59 | 60 | 'DATA', |
60 | 61 | 'DEC', |
62 | + 'DELETE', | |
61 | 63 | 'DIM', |
62 | 64 | 'DO', |
63 | 65 | 'ELSE', |
@@ -71,6 +73,7 @@ var namearray=[ | ||
71 | 73 | 'FEOF', |
72 | 74 | 'FGET', |
73 | 75 | 'FGETC', |
76 | + 'FIELD', | |
74 | 77 | 'FILE', |
75 | 78 | 'FINPUT', |
76 | 79 | 'FLEN', |
@@ -104,15 +107,21 @@ var namearray=[ | ||
104 | 107 | 'MODF', |
105 | 108 | 'MUSIC', |
106 | 109 | 'NEXT', |
110 | + 'NEW', | |
107 | 111 | 'NOT', |
108 | 112 | 'PCG', |
109 | 113 | 'PEEK', |
114 | + 'PEEK16', | |
115 | + 'PEEK32', | |
110 | 116 | 'PI', |
111 | 117 | 'POINT', |
112 | 118 | 'POKE', |
119 | + 'POKE16', | |
120 | + 'POKE32', | |
113 | 121 | 'POW', |
114 | 122 | 'PRINT', |
115 | 123 | 'PSET', |
124 | + 'PUBLIC', | |
116 | 125 | 'PUTBMP', |
117 | 126 | 'READ', |
118 | 127 | 'REM', |
@@ -237,7 +237,7 @@ char* clear_statement(){ | ||
237 | 237 | return 0; |
238 | 238 | } |
239 | 239 | |
240 | -char* poke_statement(){ | |
240 | +char* poke_statement_sub(int bits){ | |
241 | 241 | char* err; |
242 | 242 | err=get_value(); |
243 | 243 | if (err) return err; |
@@ -251,7 +251,18 @@ char* poke_statement(){ | ||
251 | 251 | check_obj_space(3); |
252 | 252 | g_object[g_objpos++]=0x8FA30004; // lw v1,4(sp) |
253 | 253 | g_object[g_objpos++]=0x27BD0004; // addiu sp,sp,4 |
254 | - g_object[g_objpos++]=0xA0620000; // sb v0,0(v1) | |
254 | + switch(bits){ | |
255 | + case 32: | |
256 | + g_object[g_objpos++]=0xAC620000; // sw v0,0(v1) | |
257 | + break; | |
258 | + case 16: | |
259 | + g_object[g_objpos++]=0xA4620000; // sh v0,0(v1) | |
260 | + break; | |
261 | + case 8: | |
262 | + default: | |
263 | + g_object[g_objpos++]=0xA0620000; // sb v0,0(v1) | |
264 | + break; | |
265 | + } | |
255 | 266 | return 0; |
256 | 267 | } |
257 | 268 |
@@ -1555,6 +1566,18 @@ char* useclass_statement(){ | ||
1555 | 1566 | |
1556 | 1567 | // Aliases follow |
1557 | 1568 | |
1569 | +char* poke_statement(){ | |
1570 | + return poke_statement_sub(8); | |
1571 | +} | |
1572 | + | |
1573 | +char* poke16_statement(){ | |
1574 | + return poke_statement_sub(16); | |
1575 | +} | |
1576 | + | |
1577 | +char* poke32_statement(){ | |
1578 | + return poke_statement_sub(32); | |
1579 | +} | |
1580 | + | |
1558 | 1581 | char* palette_statement(){ |
1559 | 1582 | return param4_statement(LIB_PALETTE); |
1560 | 1583 | } |
@@ -1637,6 +1660,8 @@ static const void* statement_list[]={ | ||
1637 | 1660 | "GOSUB ",gosub_statement, |
1638 | 1661 | "RETURN",return_statement, |
1639 | 1662 | "POKE ",poke_statement, |
1663 | + "POKE16 ",poke16_statement, | |
1664 | + "POKE32 ",poke32_statement, | |
1640 | 1665 | "FOR ",for_statement, |
1641 | 1666 | "NEXT",next_statement, |
1642 | 1667 | "LET ",let_statement, |
@@ -18,111 +18,115 @@ | ||
18 | 18 | */ |
19 | 19 | |
20 | 20 | static const int reserved_var_names[]={ |
21 | - 0x000106b8, //ABS | |
22 | - 0x0001f67c, //ACOS | |
23 | - 0x0002414c, //ARGS | |
24 | - 0x0001090c, //ASC | |
25 | - 0x0002469f, //ASIN | |
26 | - 0x00024a8f, //ATAN | |
27 | - 0x002f7c1e, //ATAN2 | |
28 | - 0x0047c31c, //BREAK | |
21 | + 0x000106b8, /*ABS*/ | |
22 | + 0x0001f67c, /*ACOS*/ | |
23 | + 0x0002414c, /*ARGS*/ | |
24 | + 0x0001090c, /*ASC*/ | |
25 | + 0x0002469f, /*ASIN*/ | |
26 | + 0x00024a8f, /*ATAN*/ | |
27 | + 0x002f7c1e, /*ATAN2*/ | |
28 | + 0x0047c31c, /*BREAK*/ | |
29 | 29 | 0x00035869, /*CALL*/ |
30 | - 0x00575afe, //CDATA | |
31 | - 0x00036c3d, //CEIL | |
32 | - 0x000111af, //CHR | |
33 | - 0x0cb1b682, //CIRCLE | |
34 | - 0x005d1ea3, //CLEAR | |
35 | - 0x00011240, //CLS | |
36 | - 0x005f66cb, //COLOR | |
37 | - 0x000112ac, //COS | |
38 | - 0x0003a041, //COSH | |
39 | - 0x00616415, //CREAD | |
40 | - 0x0de593fb, //CURSOR | |
41 | - 0x00040fbe, //DATA | |
30 | + 0x00575afe, /*CDATA*/ | |
31 | + 0x00036c3d, /*CEIL*/ | |
32 | + 0x000111af, /*CHR*/ | |
33 | + 0x0cb1b682, /*CIRCLE*/ | |
34 | + 0x005d1ea3, /*CLEAR*/ | |
35 | + 0x00011240, /*CLS*/ | |
36 | + 0x005f66cb, /*COLOR*/ | |
37 | + 0x000112ac, /*COS*/ | |
38 | + 0x0003a041, /*COSH*/ | |
39 | + 0x00616415, /*CREAD*/ | |
40 | + 0x0de593fb, /*CURSOR*/ | |
41 | + 0x00040fbe, /*DATA*/ | |
42 | + 0x00011644, /*DEC*/ | |
42 | 43 | 0x0fe19c42, /*DELETE*/ |
43 | - 0x00011644, //DEC | |
44 | - 0x000116de, //DIM | |
45 | - 0x000100a8, //DO | |
46 | - 0x0004fd8e, //ELSE | |
47 | - 0x1434a177, //ELSEIF | |
48 | - 0x00011c99, //END | |
49 | - 0x0091c927, //ENDIF | |
50 | - 0x00053854, //EXEC | |
51 | - 0x00011e0d, //EXP | |
52 | - 0x000579c8, //FABS | |
53 | - 0x16e3d4be, //FCLOSE | |
54 | - 0x00058fcf, //FEOF | |
55 | - 0x00059895, //FGET | |
56 | - 0x00a67500, //FGETC | |
44 | + 0x000116de, /*DIM*/ | |
45 | + 0x000100a8, /*DO*/ | |
46 | + 0x0004fd8e, /*ELSE*/ | |
47 | + 0x1434a177, /*ELSEIF*/ | |
48 | + 0x00011c99, /*END*/ | |
49 | + 0x0091c927, /*ENDIF*/ | |
50 | + 0x00053854, /*EXEC*/ | |
51 | + 0x00011e0d, /*EXP*/ | |
52 | + 0x000579c8, /*FABS*/ | |
53 | + 0x16e3d4be, /*FCLOSE*/ | |
54 | + 0x00058fcf, /*FEOF*/ | |
55 | + 0x00059895, /*FGET*/ | |
56 | + 0x00a67500, /*FGETC*/ | |
57 | 57 | 0x00a7e061, /*FIELD*/ |
58 | - 0x0005a3a2, //FILE | |
59 | - 0x177f0ca5, //FINPUT | |
60 | - 0x0005b1df, //FLEN | |
61 | - 0x00aa3445, //FLOAT | |
62 | - 0x00aa363b, //FLOOR | |
63 | - 0x0005b84d, //FMOD | |
64 | - 0x00ac5c9f, //FOPEN | |
65 | - 0x000121db, //FOR | |
66 | - 0x18352839, //FPRINT | |
67 | - 0x0005c865, //FPUT | |
68 | - 0x00ad2e40, //FPUTC | |
69 | - 0x00aefdec, //FSEEK | |
70 | - 0x00063b90, //GCLS | |
71 | - 0x1a808bcb, //GCOLOR | |
72 | - 0x00c60f03, //GOSUB | |
73 | - 0x0006796c, //GOTO | |
74 | - 0x1bcfcc39, //GPRINT | |
75 | - 0x00012a99, //HEX | |
76 | - 0x00010153, //IF | |
77 | - 0x00f8701a, //INKEY | |
78 | - 0x00f88ba5, //INPUT | |
79 | - 0x000130e9, //INT | |
80 | - 0x00092084, //KEYS | |
81 | - 0x013be43d, //LABEL | |
82 | - 0x00013ecf, //LEN | |
83 | - 0x00013ed5, //LET | |
84 | - 0x0009e96a, //LINE | |
85 | - 0x00014030, //LOG | |
86 | - 0x0145f324, //LOG10 | |
87 | - 0x000a07f9, //LOOP | |
88 | - 0x000abca3, //MODF | |
89 | - 0x016418d4, //MUSIC | |
90 | - 0x000b4321, //NEXT | |
91 | - 0x000148f8, //NEW | |
92 | - 0x00014a5d, //NOT | |
93 | - 0x000152c0, //PCG | |
94 | - 0x000cacec, //PEEK | |
95 | - 0x00010252, //PI | |
96 | - 0x01ac8479, //POINT | |
97 | - 0x000ce05e, //POKE | |
98 | - 0x00015480, //POW | |
99 | - 0x01aea739, //PRINT | |
100 | - 0x000cf3d5, //PSET | |
58 | + 0x0005a3a2, /*FILE*/ | |
59 | + 0x177f0ca5, /*FINPUT*/ | |
60 | + 0x0005b1df, /*FLEN*/ | |
61 | + 0x00aa3445, /*FLOAT*/ | |
62 | + 0x00aa363b, /*FLOOR*/ | |
63 | + 0x0005b84d, /*FMOD*/ | |
64 | + 0x00ac5c9f, /*FOPEN*/ | |
65 | + 0x000121db, /*FOR*/ | |
66 | + 0x18352839, /*FPRINT*/ | |
67 | + 0x0005c865, /*FPUT*/ | |
68 | + 0x00ad2e40, /*FPUTC*/ | |
69 | + 0x00aefdec, /*FSEEK*/ | |
70 | + 0x00063b90, /*GCLS*/ | |
71 | + 0x1a808bcb, /*GCOLOR*/ | |
72 | + 0x00c60f03, /*GOSUB*/ | |
73 | + 0x0006796c, /*GOTO*/ | |
74 | + 0x1bcfcc39, /*GPRINT*/ | |
75 | + 0x00012a99, /*HEX*/ | |
76 | + 0x00010153, /*IF*/ | |
77 | + 0x00f8701a, /*INKEY*/ | |
78 | + 0x00f88ba5, /*INPUT*/ | |
79 | + 0x000130e9, /*INT*/ | |
80 | + 0x00092084, /*KEYS*/ | |
81 | + 0x013be43d, /*LABEL*/ | |
82 | + 0x00013ecf, /*LEN*/ | |
83 | + 0x00013ed5, /*LET*/ | |
84 | + 0x0009e96a, /*LINE*/ | |
85 | + 0x00014030, /*LOG*/ | |
86 | + 0x0145f324, /*LOG10*/ | |
87 | + 0x000a07f9, /*LOOP*/ | |
88 | + 0x000abca3, /*MODF*/ | |
89 | + 0x016418d4, /*MUSIC*/ | |
90 | + 0x000b4321, /*NEXT*/ | |
91 | + 0x000148f8, /*NEW*/ | |
92 | + 0x00014a5d, /*NOT*/ | |
93 | + 0x000152c0, /*PCG*/ | |
94 | + 0x000cacec, /*PEEK*/ | |
95 | + 0x3b1c6aea, /*PEEK16*/ | |
96 | + 0x3b1c6b2e, /*PEEK32*/ | |
97 | + 0x00010252, /*PI*/ | |
98 | + 0x01ac8479, /*POINT*/ | |
99 | + 0x000ce05e, /*POKE*/ | |
100 | + 0x3c20dc0a, /*POKE16*/ | |
101 | + 0x3c20dc4e, /*POKE32*/ | |
102 | + 0x00015480, /*POW*/ | |
103 | + 0x01aea739, /*PRINT*/ | |
104 | + 0x000cf3d5, /*PSET*/ | |
101 | 105 | 0x3cb45fa4, /*PUBLIC*/ |
102 | - 0x3cc0fe21, //PUTBMP | |
103 | - 0x000e18d5, //READ | |
104 | - 0x00015d2e, //REM | |
105 | - 0x425c9703, //RETURN | |
106 | - 0x00015e69, //RND | |
107 | - 0x45c26d49, //SCROLL | |
108 | - 0x00016287, //SGN | |
109 | - 0x000162cf, //SIN | |
110 | - 0x000ee52d, //SINH | |
111 | - 0x01f9a429, //SOUND | |
112 | - 0x000f0e49, //SQRT | |
113 | - 0x47f711de, //SYSTEM | |
114 | - 0x000166bf, //TAN | |
115 | - 0x000f72ed, //TANH | |
116 | - 0x02182fee, //TVRAM | |
117 | - 0x022c2a2d, //UNTIL | |
118 | - 0x4e8887d0, //USEPCG | |
119 | - 0x4e88a5f3, //USEVAR | |
120 | - 0x000170dd, //VAL | |
121 | - 0x000170e3, //VAR | |
122 | - 0x00119505, //WAIT | |
123 | - 0x0011a9e9, //WEND | |
124 | - 0x025aef62, //WHILE | |
125 | - 0x025b8d75, //WIDTH | |
106 | + 0x3cc0fe21, /*PUTBMP*/ | |
107 | + 0x000e18d5, /*READ*/ | |
108 | + 0x00015d2e, /*REM*/ | |
109 | + 0x425c9703, /*RETURN*/ | |
110 | + 0x00015e69, /*RND*/ | |
111 | + 0x45c26d49, /*SCROLL*/ | |
112 | + 0x00016287, /*SGN*/ | |
113 | + 0x000162cf, /*SIN*/ | |
114 | + 0x000ee52d, /*SINH*/ | |
115 | + 0x01f9a429, /*SOUND*/ | |
116 | + 0x000f0e49, /*SQRT*/ | |
117 | + 0x47f711de, /*SYSTEM*/ | |
118 | + 0x000166bf, /*TAN*/ | |
119 | + 0x000f72ed, /*TANH*/ | |
120 | + 0x02182fee, /*TVRAM*/ | |
121 | + 0x022c2a2d, /*UNTIL*/ | |
122 | + 0x4e8887d0, /*USEPCG*/ | |
123 | + 0x4e88a5f3, /*USEVAR*/ | |
124 | + 0x000170dd, /*VAL*/ | |
125 | + 0x000170e3, /*VAR*/ | |
126 | + 0x00119505, /*WAIT*/ | |
127 | + 0x0011a9e9, /*WEND*/ | |
128 | + 0x025aef62, /*WHILE*/ | |
129 | + 0x025b8d75, /*WIDTH*/ | |
126 | 130 | // Additional names follow |
127 | 131 | ADDITIONAL_RESERVED_VAR_NAMES |
128 | 132 | }; |