|
|
| Author |
Message |
stevech
Joined: 23 Feb 2006
Posts: 657
|
|
Posted: 01 November 2006, 3:38 AM Post subject: Register.PersistentSize et al as compile-time constants |
|
|
Correct? ...
Things like
Register.PersistentSize
could be but aren't evaluated at compile-time.
Thus, I must keep my #if and const defs so as to be usable for DIM. |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 01 November 2006, 3:48 AM Post subject: Re: Register.PersistentSize et al as compile-time constants |
|
|
| stevech wrote: | | Register.PersistentSize could be but [isn't] evaluated at compile-time. |
Register.PersistentSize is constant at compile-time evidenced by this listing:
| Code: | Sub Main()
ps = Register.PersistentSize
0014 1be003 PSHI_W 0x03e0 (992)
0017 21a000 POPA_W 0x00a0 (160)
End Sub
001a 06 RET |
You are correct, however, that the compiler doesn't treat it like a constant for the purposes that you mentioned. It probably should. |
|
| Back to top |
|
 |
stevech
Joined: 23 Feb 2006
Posts: 657
|
|
Posted: 01 November 2006, 3:56 AM Post subject: |
|
|
like
const PMsize = Register.PersistentSize
...
...
const infoMax = (PMsize - N) \ sizeof(MyType)
or
DIM info(PMSize - M) as BYTE |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 01 November 2006, 4:15 AM Post subject: |
|
|
Understood. I probably should have thought of that. I've modified the tables to make some of the Register.xxx items look like constants. In particular,
Register.RamStart
Register.PersistentStart
Register.PersistentSize
I can't also make Register.RamSize constant because of the possibility of the presence of external RAM on future ZX models. It may be possible to have it be a constant for targets that have a constant RAM size and be a read-only variable for others. That may cause more confusion than it's worth, though. |
|
| Back to top |
|
 |
stevech
Joined: 23 Feb 2006
Posts: 657
|
|
Posted: 01 November 2006, 5:01 AM Post subject: |
|
|
sounds good.
Register.PersistentSize
would be a constant? For any given VM release, I suppose.
or perhaps it's the size of the chip's EEPROM, excluding the portion used by the VM. |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 01 November 2006, 6:18 AM Post subject: |
|
|
| stevech wrote: | | perhaps it's the size of the chip's EEPROM, excluding the portion used by the VM. |
That is correct. A section is reserved for system use; most of it unused at present. |
|
| Back to top |
|
 |
stevech
Joined: 23 Feb 2006
Posts: 657
|
|
Posted: 01 November 2006, 6:21 AM Post subject: |
|
|
| while you're twiddling, maybe a constant or run-time to discover how much of the persistent EEPROM area is reserved, given this region begins at zero. |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 01 November 2006, 16:11 PM Post subject: |
|
|
| stevech wrote: | | while you're twiddling, maybe a constant or run-time to discover how much of the persistent EEPROM area is reserved, given this region begins at zero. |
That is available, by implication, in Register.PersistentStart. Currently, Register.PersistentSize will always have the value 32, implying that the first 32 bytes are reserved for system use. For the mega32-based ZX devices, Register.PersistentSize will be 992. The sum of these two is the total number of bytes of internal EEPROM.
Register.PersistentSize - Register.PersistentUsed gives the number of unused bytes of Persistent Memory in the user portion of the internal EEPROM and Register.PersistentStart + Register.PersistentUsed gives the address of the first unused byte.
I believe that these three values completely describe the allocation of the PersistentMemory resource. |
|
| Back to top |
|
 |
stevech
Joined: 23 Feb 2006
Posts: 657
|
|
Posted: 02 November 2006, 0:52 AM Post subject: |
|
|
| ah, got it. Those are too new to be in the docs yet. |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 02 November 2006, 1:53 AM Post subject: |
|
|
| stevech wrote: | | ah, got it. Those are too new to be in the docs yet. |
That's true. However, the meaning of each is the same as the similarly named values for RAM. |
|
| Back to top |
|
 |
|