Hi Rob! Yes, there have been discussions about this already. I think it is a pity to waste RAM that could easily be made accessible.
Memory allocation is a confusing subject anyway, especially when large structures are used. Example: include 16f688 const array_size=19 var dword dummy[array_size] var byte counter for array_size using counter loop dummy[counter]=0 end loop It compiles (as part of a bigger program) Data area: 134 of 240 used Software stack available: 80 bytes The chip has 256 bytes RAM, the compiler only says 240. That's what you're addressing here. But then... 134 of 240 used, makes 106 available. The compiler only says 80. 80 is the biggest free -contiguous- RAM space. Now, let's increase array_size to 20: Data area: 138 of 240 used Software stack available: 80 bytes 4 bytes more used, still at least 80 free. If array_size is increased to 21, it is clear that another four bytes of the unused space will be used. But no: 16f688_print.jal:193: error: Out of data space! On a PIC18 device, this compiles without error. To understand this, you have to read something about paging and indirect adressing methods. Arrays is the one thing, the other are large variables. Some examples for PIC18 chips: const max_var_size=256 var byte*max_var_size var1, var2 var1=1000 var2=var1+512 var1=var2 var2=var2<<16 var1=var1<<8 var2=var2+var1 --The above lines compile for max_var_size up to 256 var2=(var2<<16)+(var2<<8) -- The above line compiles for max_var_size up to 128 var2=var2*(65536+256) -- This line compiles for max_var_size up to 85 var2=var2 / 15 -- This line compiles for max_var_size up to 64 If multiplication or division require variable limiting, the compiler message is a bit more explanatory: error: no space for :_pic_state (need=512 available=3800) While it can be still confusing, for 512 is smaller than 3800, when you know about paging you can guess that you have to keep the size of _pic_state below 256 bytes. Err, I think I've gone a bit off topic ;-) I would appreciate the usage of as much RAM as possible. Even better than declaring a new chunk of RAM for the shared bytes would be to add the shared bytes to the largest unshared data block. This way not only the overall number of bytes, but also the maximum structure size would be increased. Greets, Kiste -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
