|
|
| Author |
Message |
DH* Guest
|
|
Posted: 14 April 2006, 12:44 PM Post subject: Total RAM |
|
|
| The ZX-24 comparison chart says 1024 bytes + ~600 bytes. Can you clarify that? Does it mean ~1600 bytes or ~600 bytes more than a BX-24P? |
|
| Back to top |
|
 |
mikep
Joined: 24 Sep 2005
Posts: 765
Location: Austin, TX
|
|
Posted: 14 April 2006, 14:38 PM Post subject: |
|
|
The 1024 bytes is used for all of the regular things you expect including global variables and task stacks. The remaining RAM from the 1024 bytes is allocated to the main task stack. Inside a particular task stack are local variables, routine parameters and intermediate calculations. If you look at the map file you will see that the first user variable is stored at location 0xa0.
The ~600 bytes is used to store dynamically allocated strings. This effectively removes the BasciX restriction on fixed length strings and allows for a lot more string storage. But remember it is still only 600 bytes.
The reason that it is quoted as approximately 600 bytes is that the remaining RAM (~424 bytes) is used by the ZBasic virtual machine for its own static data and call stack.
As near as I can tell, here is the memory map for the Atmega32:
| Code: | 0x0000 0x005F AVR registers and I/0 ports
0x0060 0x009F ZBasic Low System RAM
0x00A0 0x049F User RAM
0x04A0 0x???? ZBasic High System RAM (e.g. SPI channels, COM ports)
0x???? -----> String Pool
<----- 0x085F ZBasic VM Stack |
Last edited by mikep on 14 April 2006, 16:14 PM; edited 1 time in total |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 14 April 2006, 15:43 PM Post subject: |
|
|
Mike's analysis is quite accurate. There is one clarification that I would make, however. The 1024 bytes is referred to as User RAM and the ~600 bytes is called the string pool. When allocated strings are used (the default) each string variable that is defined consumes 4 bytes of User RAM plus additional bytes (0 - 255) from the string pool for the characters of the string.
There is additional detail in the Data Type Implementation section of the Reference Manual. In particular, it should be noted that simply assigning a value to a string variable doesn't necessarily consume string pool space. The compiler attempts to generate code that minimizes the use string pool memory by referring to string data in Program Memory and Persistent Memory when it can. A string that is constructed at run-time (e.g. using MakeString(), Mid(), UCase(), string append, etc.) will consume string pool memory if it has a non-zero length. |
|
| Back to top |
|
 |
stevech
Joined: 23 Feb 2006
Posts: 657
|
|
Posted: 14 April 2006, 22:43 PM Post subject: |
|
|
| ZBasic does a stellar job of handling strings in these small RAM micros and in the Harvard architecture. I've seen none better - including GCC, Codevision AVR, FastAVR and BASCOM. |
|
| Back to top |
|
 |
|