ugl
This commit is contained in:
parent
3a2dece94a
commit
811532b280
|
@ -92,7 +92,7 @@ void ugl_ResolveSymbols(void)
|
|||
break;
|
||||
default: /* assume 0x0f, extended command */
|
||||
switch( cmd )
|
||||
{
|
||||
{
|
||||
case BC_CMD_LOAD_0:
|
||||
break;
|
||||
case BC_CMD_LOAD_1:
|
||||
|
@ -121,12 +121,11 @@ void ugl_ResolveSymbols(void)
|
|||
|
||||
break;
|
||||
case BC_CMD_CALL_PROCEDURE:
|
||||
case BC_CMD_CALL_PROCEDURE_POP_STACK:
|
||||
val = code[0];
|
||||
val <<= 8;
|
||||
val |= code[1];
|
||||
|
||||
ugl_glog("Resolve CALL Procedre '%s'", ugl_label_name[val]);
|
||||
ugl_glog("Resolve CALL Procedre '%s' pos=%u", ugl_label_name[val], ugl_GetLabelBytecodePos(val));
|
||||
|
||||
val = ugl_GetLabelBytecodePos(val);
|
||||
|
||||
|
@ -135,6 +134,8 @@ void ugl_ResolveSymbols(void)
|
|||
*code = val&255;
|
||||
code++;
|
||||
|
||||
break;
|
||||
case BC_CMD_POP_ARG_STACK:
|
||||
break;
|
||||
default:
|
||||
ugl_err("Resolve: Unexpected command");
|
||||
|
|
|
@ -124,7 +124,8 @@ void bc_exec(bc_t *bc, uint8_t *code)
|
|||
case BC_CMD_RETURN_FROM_PROCEDURE:
|
||||
if ( bc->return_stack_pointer == 0 )
|
||||
return; /* stop execution */
|
||||
bc->code_pos = bc_pop_from_arg_stack(bc);
|
||||
bc_push_on_arg_stack(bc, bc_pop_from_return_stack(bc)); /* copy return value on arg stack */
|
||||
bc->code_pos = bc_pop_from_return_stack(bc);
|
||||
break;
|
||||
case BC_CMD_JUMP_NOT_ZERO:
|
||||
val = bc->code[bc->code_pos];
|
||||
|
@ -149,11 +150,16 @@ void bc_exec(bc_t *bc, uint8_t *code)
|
|||
bc->code_pos = val;
|
||||
break;
|
||||
case BC_CMD_CALL_PROCEDURE:
|
||||
val = bc_get_value(code);
|
||||
//bc_push_on_return_stack(bc, 0);
|
||||
//bc_push_on_return_stack(bc, 0);
|
||||
break;
|
||||
case BC_CMD_CALL_PROCEDURE_POP_STACK:
|
||||
val = bc->code[bc->code_pos];
|
||||
bc->code_pos++;
|
||||
val <<= 8;
|
||||
val |= bc->code[bc->code_pos];
|
||||
bc->code_pos++;
|
||||
|
||||
bc_push_on_return_stack(bc, bc->code_pos); /* return position */
|
||||
bc_push_on_return_stack(bc, 0); /* return value */
|
||||
bc->code_pos = val;
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -59,7 +59,7 @@ extern bc_buildin_fn bc_buildin_list[];
|
|||
/* lower 4 bit: 15, upper 4 bit: 6 --> adr are next 16 bit */
|
||||
#define BC_CMD_CALL_PROCEDURE (0x06f)
|
||||
/* lower 4 bit: 15, upper 4 bit: 7 --> adr are next 16 bit */
|
||||
#define BC_CMD_CALL_PROCEDURE_POP_STACK (0x07f)
|
||||
#define BC_CMD_POP_ARG_STACK (0x07f)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -212,16 +212,15 @@ void ugl_bytecode_call_procedure(const char *name, int is_toplevel)
|
|||
ugl_plog("BC call %sbytecode '%s'", is_toplevel?"toplevel ":"", name);
|
||||
idx = ugl_GetLabel(name);
|
||||
|
||||
if ( is_toplevel == 0 )
|
||||
{
|
||||
ugl_AddBytecode(BC_CMD_CALL_PROCEDURE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ugl_AddBytecode(BC_CMD_CALL_PROCEDURE_POP_STACK );
|
||||
}
|
||||
ugl_AddBytecode(BC_CMD_CALL_PROCEDURE );
|
||||
|
||||
ugl_AddBytecode(idx>>8);
|
||||
ugl_AddBytecode(idx&0x0ff);
|
||||
|
||||
if ( is_toplevel != 0 )
|
||||
{
|
||||
ugl_AddBytecode(BC_CMD_POP_ARG_STACK );
|
||||
}
|
||||
}
|
||||
|
||||
void ugl_bytecode_constant_value(long num)
|
||||
|
|
Loading…
Reference in New Issue