manualy generated blinky opcodes

This commit is contained in:
e.gavrin
2014-07-03 16:23:25 +04:00
parent 1c4873f4b6
commit 3fde3400f4
33 changed files with 186 additions and 102 deletions
+84 -7
View File
@@ -13,21 +13,98 @@
* limitations under the License.
*/
#include "opcode.h"
#include "opcodes.h"
#include <stdio.h>
#include <stdlib.h>
OP_DEFINITION (control_op)
void
opfunc_loop_inf (union __opcodes opdata)
{
printf ("control_op %d, %d\n", arg1, arg2);
printf ("loop_inf:idx:%d\n",
opdata.op_loop_inf.opcode_idx);
}
OP_DEFINITION (decl_op)
void
opfunc_op_call_1 (union __opcodes opdata)
{
printf ("decl_op %d, %d\n", arg1, arg2);
printf ("op_call_1:idx:%d:%d\n",
opdata.op_call_1.name_literal_idx,
opdata.op_call_1.arg_literal_idx);
}
OP_DEFINITION (call_op)
void
opfunc_op_jmp (union __opcodes opdata)
{
printf ("call_op %d, %d\n", arg1, arg2);
printf ("op_jmp:idx:%d\n",
opdata.op_jmp.opcode_idx);
}
void proxy_loop_inf (union __opcodes opdata)
{
opdata.op_loop_inf.opfunc_ptr (opdata);
}
void proxy_op_call_1 (union __opcodes opdata)
{
opdata.op_call_1.opfunc_ptr (opdata);
}
void proxy_op_jmp (union __opcodes opdata)
{
opdata.op_jmp.opfunc_ptr (opdata);
}
void
save_op_jmp (FILE *file, union __opcodes opdata, int arg1)
{
if (file == NULL)
{
return;
}
opdata.opfunc_ptr = proxy_op_jmp;
opdata.op_jmp.opfunc_ptr = opfunc_op_jmp;
opdata.op_jmp.opcode_idx = arg1;
fwrite (&opdata, sizeof (union __opcodes), 1, file);
}
void
save_op_call_1 (FILE *file, union __opcodes opdata, int arg1, int arg2)
{
if (file == NULL)
{
return;
}
opdata.opfunc_ptr = proxy_op_call_1;
opdata.op_call_1.opfunc_ptr = opfunc_op_call_1;
opdata.op_call_1.name_literal_idx = arg1;
opdata.op_call_1.arg_literal_idx = arg2;
fwrite (&opdata, sizeof (union __opcodes), 1, file);
}
void
save_op_loop_inf (FILE *file, union __opcodes opdata, int arg1)
{
if (file == NULL)
{
return;
}
opdata.opfunc_ptr = proxy_loop_inf;
opdata.op_loop_inf.opfunc_ptr = opfunc_loop_inf;
opdata.op_loop_inf.opcode_idx = arg1;
fwrite (&opdata, sizeof (union __opcodes), 1, file);
}