Skip to content

"convert" function overflow #2

@OlejnikKristina

Description

@OlejnikKristina

"convert" function overflow when its works in this function --> bool        op_ld(t_cursor *cursor, t_vm *vm);. You can see it with player turtle.cor.

The part of the function op_ld where is problem hidden:

else if (args[0] == DIR && args[1] == REG)
{
	cursor->reg[vm->arena[cursor->pos + 6] - 1] =
	vm->arena[cursor->pos + convert(&vm->arena[cursor->pos + 2], 4)];
	ft_printf("loaded %d into r%d = %d\n", vm->arena[cursor->pos + convert(&vm->arena[cursor->pos + 2], 4)],
	vm->arena[cursor->pos + 6], cursor->reg[vm->arena[cursor->pos + 6] - 1]);
}

I changed a bit. Not sure if it's better now ...

else if (args[0] == DIR && args[1] == REG)
{
	reg_num = vm->arena[cursor->pos + 6] - 1;
	reg_val = vm->arena[cursor->pos + 2];
	// ft_printf("\nREG NUM [%d] DIR VAL dec(%d) hex[%x] ", reg_num, reg_val, reg_val);
	// ft_printf("Dir val converted: %d\n", convert(&vm->arena[cursor->pos + 2], 4));
	cursor->reg[reg_num] = reg_val;
	cursor->carry = (reg_val == 0) ? true : false;
}

Screen Shot 2020-01-07 at 8 09 35 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions