Menu

#18 Unary negation bug

open
nobody
None
5
2004-05-25
2004-05-25
Anonymous
No

There seems to be a problem with unary negation.
Instead of just negating the number, it seems to
subtract it from 1. For example:
x = -y
seems to result in:
x = 1 - y

Looking at the code, I think I see the reason, but
haven't really gone into too much detail.

In the file codegen.c, I see the section:
case op_mminus:{
q1->first = code_node(p->first, my_args);
q1->next = a1 = new_node(p->loc, node_asm);
a1->opcode = opcode_sublw;
a1->first = c1 = new_node(p->loc,
node_const);
c1->type = type_byte;
c1->value = new_value(type_universal, 1);
break;
}

Should the c1->value not be zero, instead of 1????
Also, should it be a universal? That I am not sure about,
as I don't know how this is handled by the compiler.

Is anyone actually still supporting JAL? Please let me
know if this is helpful or if I am just "out to lunch".

THanks,

Kevin Wood
wood@kos.net

Discussion


Log in to post a comment.

MongoDB Logo MongoDB