OpenCores
no use no use 1/1 no use no use
Compiling the source code with large static array size
by Unknown on Jun 14, 2004
Not available!
Dear all,
I encounterred a problem when compiling the source code using or32-
gcc and simulating in or32 simulator.

When I created a large static array , e.g :

int main()
{
int aii[100000];
int i;

for (i=0 ; i {
aii[i+1]
}
........
return 0;
}

After compiled the source code and got the Assembley code :

00002000 :
2000: 19 60 00 01 l.movhi r11,0x1
2004: a9 6b 3a 30 l.ori r11,r11,0x3a30
2008: e0 21 58 02 l.sub r1,r1,r11
200c: d4 01 48 00 l.sw 0x0(r1),r9
2010: d4 01 50 04 l.sw 0x4(r1),r10
2014: d4 01 60 08 l.sw 0x8(r1),r12
2018: d4 01 70 0c l.sw 0xc(r1),r14
201c: d4 01 80 10 l.sw 0x10(r1),r16
2020: d4 01 90 14 l.sw 0x14(r1),r18
2024: d4 01 a0 18 l.sw 0x18(r1),r20
2028: d4 01 b0 1c l.sw 0x1c(r1),r22

.....................

The series of l.sw instructions were not belong to my "for loop".
While did simulation until the instruction "l.sw 0x0(r1),r9", the value of
register "r1" became very large (== fffff2e8). The simulation gave error
message "EXCEPTION: write out of memory (32-bit access to fffff2ec)"

Do anyone know the use of these l.sw instructions ? And how to limit
the register "r1" 's value not become too large during compilation ?

Thank you very much !

Regards,
Yu Chi Wai
Compiling the source code with large static array size
by Unknown on Jun 14, 2004
Not available!
* y_chi_wai2003@yahoo.com.hk (y_chi_wai2003@yahoo.com.hk) wrote:
Dear all,
I encounterred a problem when compiling the source code using or32-
gcc and simulating in or32 simulator.

When I created a large static array , e.g :

int main()
{
int aii[100000];
int i;

for (i=0 ; i {
aii[i+1]
}
........
return 0;
}

After compiled the source code and got the Assembley code :

00002000 :
2000: 19 60 00 01 l.movhi r11,0x1
2004: a9 6b 3a 30 l.ori r11,r11,0x3a30
2008: e0 21 58 02 l.sub r1,r1,r11
200c: d4 01 48 00 l.sw 0x0(r1),r9
2010: d4 01 50 04 l.sw 0x4(r1),r10
2014: d4 01 60 08 l.sw 0x8(r1),r12
2018: d4 01 70 0c l.sw 0xc(r1),r14
201c: d4 01 80 10 l.sw 0x10(r1),r16
2020: d4 01 90 14 l.sw 0x14(r1),r18
2024: d4 01 a0 18 l.sw 0x18(r1),r20
2028: d4 01 b0 1c l.sw 0x1c(r1),r22

.....................

The series of l.sw instructions were not belong to my "for loop".
While did simulation until the instruction "l.sw 0x0(r1),r9", the value of
register "r1" became very large (== fffff2e8). The simulation gave error
message "EXCEPTION: write out of memory (32-bit access to fffff2ec)"

Do anyone know the use of these l.sw instructions ? And how to limit
the register "r1" 's value not become too large during compilation ?

Thank you very much !


you busted the stack. aii[100000] was allocated on stack, but there wasn't
that much space. (stack grows down)... try enlarging the stack
or use dynamic allocation...

regards,
p.

Compiling the source code with large static array size
by Unknown on Jun 14, 2004
Not available!
int main() { int aii[100000]; ^^^^^^ This is not a static array; it will be created on the stack, hence the use of r1. So it is quite possible you don't have enough stack which is why you got the error. Did you mean to do the following?: int main() { static int aii[100000]; Robert Cragie, Design Engineer _______________________________________________________________ Jennic Ltd, Furnival Street, Sheffield, S1 4QT, UK http://www.jennic.com Tel: +44 (0) 114 281 2655 _______________________________________________________________
-----Original Message----- From: openrisc-bounces@opencores.org [mailto:openrisc-bounces@opencores.org]On Behalf Of y_chi_wai2003@yahoo.com.hk Sent: 14 June 2004 08:48 To: openrisc@opencores.org Subject: [openrisc] Compiling the source code with large static array size Dear all, I encounterred a problem when compiling the source code using or32- gcc and simulating in or32 simulator. When I created a large static array , e.g : int main() { int aii[100000]; int i; for (i=0 ; i: 2000: 19 60 00 01 l.movhi r11,0x1 2004: a9 6b 3a 30 l.ori r11,r11,0x3a30 2008: e0 21 58 02 l.sub r1,r1,r11 200c: d4 01 48 00 l.sw 0x0(r1),r9 2010: d4 01 50 04 l.sw 0x4(r1),r10 2014: d4 01 60 08 l.sw 0x8(r1),r12 2018: d4 01 70 0c l.sw 0xc(r1),r14 201c: d4 01 80 10 l.sw 0x10(r1),r16 2020: d4 01 90 14 l.sw 0x14(r1),r18 2024: d4 01 a0 18 l.sw 0x18(r1),r20 2028: d4 01 b0 1c l.sw 0x1c(r1),r22 ..................... The series of l.sw instructions were not belong to my "for loop". While did simulation until the instruction "l.sw 0x0(r1),r9", the value of register "r1" became very large (== fffff2e8). The simulation gave error message "EXCEPTION: write out of memory (32-bit access to fffff2ec)" Do anyone know the use of these l.sw instructions ? And how to limit the register "r1" 's value not become too large during compilation ? Thank you very much ! Regards, Yu Chi Wai _______________________________________________ http://www.opencores.org/mailman/listinfo/openrisc



Compiling the source code with large static array size
by Unknown on Jun 15, 2004
Not available!
Thank you very much for your answer !! I tried to use : static int aii[100000]; the following assembly code generated : 00002000 : 2000: 9c 21 ff d0 l.addi r1,r1,0xffffffd0 2004: d4 01 48 00 l.sw 0x0(r1),r9 2008: d4 01 50 04 l.sw 0x4(r1),r10 200c: d4 01 60 08 l.sw 0x8(r1),r12 The error "EXCEPTION: write out of memory (32-bit access to > fffff2ec)" didn't occur anymore . Do you know where the static array aii will be stored (in the memory) ? It shouldn't be stored in stack ? Thanks !! Regards, Yu Chi Wai ----- Original Message ----- From: Matjaz Breskvarphoenix@o...> To: Date: Mon Jun 14 10:24:52 CEST 2004 Subject: [openrisc] Compiling the source code with large static array size
* y_chi_wai2003@y... (y_chi_wai2003@y...) wrote:
> Dear all,
> I encounterred a problem when compiling the source code using

or32-
> gcc and simulating in or32 simulator.
>
> When I created a large static array , e.g :
>
> int main()
> {
> int aii[100000];
> int i;
>
> for (i=0 ; i> {
> aii[i+1]
> }
> ........
> return 0;
> }
>
> After compiled the source code and got the Assembley code :
>
> 00002000 :
> 2000: 19 60 00 01 l.movhi r11,0x1
> 2004: a9 6b 3a 30 l.ori r11,r11,0x3a30
> 2008: e0 21 58 02 l.sub r1,r1,r11
> 200c: d4 01 48 00 l.sw 0x0(r1),r9
> 2010: d4 01 50 04 l.sw 0x4(r1),r10
> 2014: d4 01 60 08 l.sw 0x8(r1),r12
> 2018: d4 01 70 0c l.sw 0xc(r1),r14
> 201c: d4 01 80 10 l.sw 0x10(r1),r16
> 2020: d4 01 90 14 l.sw 0x14(r1),r18
> 2024: d4 01 a0 18 l.sw 0x18(r1),r20
> 2028: d4 01 b0 1c l.sw 0x1c(r1),r22
>
> .....................
>
> The series of l.sw instructions were not belong to my

"for loop".
> While did simulation until the instruction "l.sw

0x0(r1),r9", the value of
> register "r1" became very large (== fffff2e8). The

simulation gave error
> message "EXCEPTION: write out of memory (32-bit access to

fffff2ec)"
>
> Do anyone know the use of these l.sw instructions ? And how to

limit
> the register "r1" 's value not become too large

during compilation ?
>
> Thank you very much !

you busted the stack. aii[100000] was allocated on stack, but there
wasn't
that much space. (stack grows down)... try enlarging the stack
or use dynamic allocation...
regards,
p.



Compiling the source code with large static array size
by Unknown on Jun 15, 2004
Not available!
On Tue, 15 Jun 2004 y_chi_wai2003@yahoo.com.hk wrote: : Do you know where the static array aii will be stored (in the memory) ? : It shouldn't be stored in stack ? It will be stored in the BSS section. ~j
no use no use 1/1 no use no use
© copyright 1999-2026 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.