jmps
This commit is contained in:
@@ -39,9 +39,9 @@ gen_bytecode (FILE *src_file)
|
|||||||
pp_finish ();
|
pp_finish ();
|
||||||
|
|
||||||
FILE *file = fopen (FILE_NAME, "w+b");
|
FILE *file = fopen (FILE_NAME, "w+b");
|
||||||
|
|
||||||
OPCODE op0;
|
OPCODE op0;
|
||||||
|
|
||||||
save_op_loop_inf (file, op0, 1);
|
save_op_loop_inf (file, op0, 1);
|
||||||
save_op_call_1 (file, op0, 0, LED_GREEN);
|
save_op_call_1 (file, op0, 0, LED_GREEN);
|
||||||
save_op_call_1 (file, op0, 0, LED_BLUE);
|
save_op_call_1 (file, op0, 0, LED_BLUE);
|
||||||
@@ -61,6 +61,8 @@ run_int ()
|
|||||||
{
|
{
|
||||||
FILE *file = fopen (FILE_NAME, "rb");
|
FILE *file = fopen (FILE_NAME, "rb");
|
||||||
OPCODE op_curr;
|
OPCODE op_curr;
|
||||||
|
__int_data.pos = 0;
|
||||||
|
|
||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
@@ -74,8 +76,11 @@ run_int ()
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__int_data.pos++;
|
||||||
|
|
||||||
op_curr.opfunc_ptr (op_curr);
|
op_curr.opfunc_ptr (op_curr);
|
||||||
|
fseek (file, __int_data.pos * sizeof (OPCODE), SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (file);
|
fclose (file);
|
||||||
|
|||||||
@@ -24,8 +24,14 @@
|
|||||||
|
|
||||||
#define FILE_NAME "application.bin"
|
#define FILE_NAME "application.bin"
|
||||||
|
|
||||||
void gen_bytecode(FILE*);
|
struct
|
||||||
void run_int();
|
{
|
||||||
|
int pos;
|
||||||
|
} __int_data;
|
||||||
|
|
||||||
|
|
||||||
|
void gen_bytecode (FILE*);
|
||||||
|
void run_int ();
|
||||||
|
|
||||||
#endif /* INTERPRETER_H */
|
#endif /* INTERPRETER_H */
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "opcodes.h"
|
#include "opcodes.h"
|
||||||
|
#include "interpreter.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -23,6 +24,8 @@ opfunc_loop_inf (OPCODE opdata)
|
|||||||
{
|
{
|
||||||
printf ("loop_inf:idx:%d\n",
|
printf ("loop_inf:idx:%d\n",
|
||||||
opdata.data.loop_inf.opcode_idx);
|
opdata.data.loop_inf.opcode_idx);
|
||||||
|
|
||||||
|
__int_data.pos = opdata.data.loop_inf.opcode_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -38,11 +41,10 @@ opfunc_op_jmp (OPCODE opdata)
|
|||||||
{
|
{
|
||||||
printf ("op_jmp:idx:%d\n",
|
printf ("op_jmp:idx:%d\n",
|
||||||
opdata.data.jmp.opcode_idx);
|
opdata.data.jmp.opcode_idx);
|
||||||
|
|
||||||
|
__int_data.pos = opdata.data.jmp.opcode_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
save_op_jmp (FILE *file, OPCODE opdata, int arg1)
|
save_op_jmp (FILE *file, OPCODE opdata, int arg1)
|
||||||
{
|
{
|
||||||
@@ -65,7 +67,7 @@ save_op_call_1 (FILE *file, OPCODE opdata, int arg1, int arg2)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
opdata.opfunc_ptr = opfunc_op_call_1;
|
opdata.opfunc_ptr = opfunc_op_call_1;
|
||||||
opdata.data.call_1.name_literal_idx = arg1;
|
opdata.data.call_1.name_literal_idx = arg1;
|
||||||
opdata.data.call_1.arg1_literal_idx = arg2;
|
opdata.data.call_1.arg1_literal_idx = arg2;
|
||||||
|
|
||||||
@@ -79,7 +81,7 @@ save_op_loop_inf (FILE *file, OPCODE opdata, int arg1)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
opdata.opfunc_ptr = opfunc_loop_inf;
|
opdata.opfunc_ptr = opfunc_loop_inf;
|
||||||
opdata.data.loop_inf.opcode_idx = arg1;
|
opdata.data.loop_inf.opcode_idx = arg1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user