/**
* power function
*/
void power() __reentrant {
unsigned int i,j;
unsigned long result;
for (i=0; i<100; i++) {
for (j=0; j<1000; j++) {
}
result = 1;
for (j=0; j<31; j++) {
result *= 2;
}
if (result != 2147483648) {
put_char('f');
break;
}
}
}
Wenn I look at the generated code, i see this:
430 ;----------------------------------------
431 ;Allocation info for local variables in function 'power'
432 ;----------------------------------------
433 ;i Allocated to stack - offset 1
434 ;j Allocated to registers r4 r5
435 ;result Allocated to registers r4 r5 r6 r7
436 ;----------------------------------------
437 ; main.c:40: void power() __reentrant {
Only "i" ist on the stack, remaining variables are in registeres. Is this a bug in sdcc ? According to manual, chapter 3.7 Parameters & Local Variables they should all be on the stack.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have this function in my main.c
/**
* power function
*/
void power() __reentrant {
unsigned int i,j;
unsigned long result;
for (i=0; i<100; i++) {
for (j=0; j<1000; j++) {
}
result = 1;
for (j=0; j<31; j++) {
result *= 2;
}
if (result != 2147483648) {
put_char('f');
break;
}
}
}
Wenn I look at the generated code, i see this:
430 ;----------------------------------------
431 ;Allocation info for local variables in function 'power'
432 ;----------------------------------------
433 ;i Allocated to stack - offset 1
434 ;j Allocated to registers r4 r5
435 ;result Allocated to registers r4 r5 r6 r7
436 ;----------------------------------------
437 ; main.c:40: void power() __reentrant {
Only "i" ist on the stack, remaining variables are in registeres. Is this a bug in sdcc ? According to manual, chapter 3.7 Parameters & Local Variables they should all be on the stack.
Not if they can be held in registers.