Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#809 mul/div in the PIC16 port

closed-fixed
5
2013-05-25
2004-09-13
Raphael Neider
No

The following code fails:

int main () {
volatile unsigned int val1, val2, res;
volatile long f1, f2, prod;

f1 = 2L;
f2 = 4L;
prod = f1 * f2; /* BUG1 */
prod = 2L * f2;
prod = f1 * 4L;
prod = 2L * 4L;

val1 = 0x30d4;
val2 = 0x123;
res = val1 / val2;
res = val1 / 0x123;
res = ((unsigned int)0x30d4) / val2; /* BUG2 */
res = ((unsigned int)0x30d4) / 0x123;

return res;
}

Compiled using "sdcc -mpic16 -p18f452 --no-crt div.c"
with SDCC : pic16 2.4.4 #838 (Sep 13 2004) (UNIX)
two bugs occur:
(BUG1) long multiplication cannot be performed natively,
fix line 700, main.c from "<= 4" to "< 4" works fine
(calls the library function)
[comment out BUG2 to compile]

(BUG2) compiling aborts here with an assertion:
Internal error: validateOpType failed in
OP_SYMBOL(IC_LEFT(ic)) @ main.c:700: expected symbol,
got value

Modifying main.c:700f to read
if((ic->op == '*')
&& (getSize(OP_SYMBOL(IC_LEFT(ic))->type) < 4))
return TRUE;
circumvents both errors.

Greetings,
Raphael Neider

Discussion

  • Vangelis Rokas
    Vangelis Rokas
    2004-09-15

    • milestone: --> fixed
    • assigned_to: nobody --> vrokas
    • status: open --> closed-fixed