Hi. I just succeded to disassemble the 2.55MP OS, and i've been looking through it for about 5 hours now, and i have gathered a few noob questions.

What i do not understand and what is absolutely crucial is the page system. I know that the calculator has RAM and Flash ROM.
RAM will loose its state after loosing power, but Flash won't, so i can think about it as a harddrive.
Now I also know that the processor can only adress up to 64kb, which isn't enough to adress all available memory.
So they divided it into chunks of 16kb called pages. And here is what i don't understand- how is this all organized?

For a long time i thought that the calculator only had 16 kb of memory, and half of it was RAM and the other was ROM. Rom began at
0, and RAM began at $4000. I thought that both the OS with the bcalls and everythign were stored in thos 16kb, but now it came out that there are about 19 of dedicated to OS.

Since the best way for me to understand this would be to write what i think now and let someone correct me if im wrong, im going to do so.

So the memory called RAM is 64 kb, and its divided into 4 pages that i don't know the numbers of. The only page that i've been using when writing small and simple ASM programs was page that is located at $8000. There is a small part of it reserved for the OS(i thought this was the whole OS Very Happy), then there si the stack at the end of it and so on, this is pretty simple. The other 3 pages i don't know anything about, how to acces them, nor what they hold.

There is also another type of memory called ROM that is 512kb( at least on 83), that is also divided into 16kb pages. In the first 19(or so) there is the OS, then there is some space for APPS, and certificates. I don't know if they can be accesed by anything but OS.
Memory layout as seen by the processor:

Code:
0000-3FFF - Bank 0: always page 0
4000-7FFF - Bank 1: page controlled by port 6
8000-BFFF - Bank 2: page controlled by port 7
C000-FFFF - Bank 3: usually RAM page 0 (0x80), controlled by port 5. Not changeable on standard 83+, can only point to a RAM page.


In general the mapping of pages to physical memory is that the high bit indicates Flash or RAM. That is, page 0 is the beginning of Flash and page 0x80 is the beginning of RAM.

Depending on the model of your calculator, the highest flash page is 1F (83+), 3F (83+ SE, 84+) or 7F (84+ SE). In the interest of simplicity I'll be using 7F as the max value in all cases here, you can just mask to the corresponding value for any model.

Flash is divided into a few regions in the hardware. Most of the space is usable in any fashion, and that's pages 0 through 7B. Some chunk of this holds OS code (some amount of space beginning at page 0, which is always OS code, and a few pages at the end), and the rest of it is the user archive (holding apps, archived variables, and it has a swap sector that we don't need to be concerned with).

Pages 7C and 7D are the "privileged" pages, which code must be executing from to write to the "privileged ports". These ports control things like the Flash write lock, and you generally don't need to be concerned with such. These also contain OS code.

Page 7E is the certificate. Again, the details of this aren't important for this conversation.

Page 7F is the boot code, which should be treated as read-only in all situations. This page contains the code that allows the calculator to receive an OS even when there isn't one loaded. There are ways to rewrite it, but it's a very bad idea unless you know exactly what you're doing.
All of the flash is readable, except the certificate (which is only readable if the flash write lock is cleared, IIRC).

RAM is two or more pages beginning at 0x80. The 83+ only has two, and all other models have either 3 or 8 (recent 84+es appear to have only 3 as a cost-cutting measure for TI). You generally shouldn't be concerned with paging RAM, but there are rare cases where it's useful. Only pages 80 and 81 are accessible to the user, and the OS uses page 82 as temporary storage during some operations. Everything else (where available) is unused (though some programs such as Omnicalc use those pages for long-term storage).

There are some limits on what pages code can be executed from. Notably, you can't run code from RAM page 0. A variety of protected ports control additional execution restrictions in Flash and RAM, but you usually don't need to care about those.

As always, WikiTI has lots of documentation about this sort of thing.
Now even after this detailed explanaition i still have some questions. You just described it as all the tutorials/guides describe it, but i still don't get it, and im sure its because im lacking some basic knowledge.

Tari wrote:
Memory layout as seen by the processor:

Code:
0000-3FFF - Bank 0: always page 0
4000-7FFF - Bank 1: page controlled by port 6
8000-BFFF - Bank 2: page controlled by port 7
C000-FFFF - Bank 3: usually RAM page 0 (0x80), controlled by port 5. Not changeable on standard 83+, can only point to a RAM page.


So what you described here is the 4 pages of RAM right? And the page 0 holds a COPY of Flash page 0 where the os is located.
Then when i think about what somebody said to me, i assume that the OS imports any Flash page it needs to Bank 1 or 2, because the code cannot be run from flash directly, is it correct?

Tari wrote:

In general the mapping of pages to physical memory is that the high bit indicates Flash or RAM. That is, page 0 is the beginning of Flash and page 0x80 is the beginning of RAM.
So the full adress is actually 3 bytes, the page, and then the 2 byte adress withing the page?

Tari wrote:

RAM is two or more pages beginning at 0x80.

So what you're saying is that the calculator doesn't actually differ between Flash and RAM as the RAM pages are just after FLASH ones and are adressed in the exact same way. So if you connect what you have written at the beginning, you can say that page 0x80 is Bank 1 and so on right?

Tari wrote:

The 83+ only has two, and all other models have either 3 or 8 (recent 84+es appear to have only 3 as a cost-cutting measure for TI).

Now this is very confuzing. Since the amount of RAM is constant 64kb, how can some calculators have up to 8 pages of it?

Im really sorry if im beeing repetitive and asking the same questions but i really want to understand it as good as i can.
jammasterz wrote:
Now even after this detailed explanaition i still have some questions. You just described it as all the tutorials/guides describe it, but i still don't get it, and im sure its because im lacking some basic knowledge.

Tari wrote:
Memory layout as seen by the processor:

Code:
0000-3FFF - Bank 0: always page 0
4000-7FFF - Bank 1: page controlled by port 6
8000-BFFF - Bank 2: page controlled by port 7
C000-FFFF - Bank 3: usually RAM page 0 (0x80), controlled by port 5. Not changeable on standard 83+, can only point to a RAM page.


So what you described here is the 4 pages of RAM right? And the page 0 holds a COPY of Flash page 0 where the os is located.
Then when i think about what somebody said to me, i assume that the OS imports any Flash page it needs to Bank 1 or 2, because the code cannot be run from flash directly, is it correct?
Wrong. Code can and is directly run from Flash. Page 0 does not hold a copy of Flash page 0; Bank 0 is mapped to Flash page 0. The memory is directly "there" in bank 0; there's no copying or indirection involved. The Bank 0-3 system is just a way of "mapping" more than 64KB of RAM, Flash, or some combination thereof into the 16-bit 64KB address space, and making sure all of the >64KB is accessible (although, obviously, not at the same time).

Quote:
Tari wrote:

In general the mapping of pages to physical memory is that the high bit indicates Flash or RAM. That is, page 0 is the beginning of Flash and page 0x80 is the beginning of RAM.
So the full adress is actually 3 bytes, the page, and then the 2 byte adress withing the page?
Sort of, but we never think of it that way. Addresses $0000 to $3FFF are the 16KB of whatever is mapped to Bank 0, $4000 to $7FFF are whatever is mapped to Bank 1, etc.

Quote:
Tari wrote:

RAM is two or more pages beginning at 0x80.

So what you're saying is that the calculator doesn't actually differ between Flash and RAM as the RAM pages are just after FLASH ones and are adressed in the exact same way. So if you connect what you have written at the beginning, you can say that page 0x80 is Bank 1 and so on right?
RAM and Flash can both be arbitrarily mapped to Banks. The only difference is that you can't write to Flash the way you write to RAM.

Quote:
Tari wrote:

The 83+ only has two, and all other models have either 3 or 8 (recent 84+es appear to have only 3 as a cost-cutting measure for TI).

Now this is very confuzing. Since the amount of RAM is constant 64kb, how can some calculators have up to 8 pages of it?
The amount of RAM is not constant at 64KB. The address space is constant at 64KB, broken into four 16KB banks, each of which is mapped to a RAM or Flash page.

Quote:
Im really sorry if im beeing repetitive and asking the same questions but i really want to understand it as good as i can.
Totally understandable.
I suggest that you read up on what an MMU does: http://en.wikipedia.org/wiki/Memory_management_unit

Now, an MMU for the Prizm and other modern PCs is used to map memory to addresses. The ez80 has an MMU and is compatible with the z80, but that isn't too relevant. Now, let me try to explain this the way I see it:

Now, the z80 is an 8 bit CPU, but it can access 16 bit addresses. That means that the CPU can only access memory from 0x0000 to 0xFFFF. Now, that is where you get the 64KB from. You can only access that memory at one time.

Now, having a computer with 64KB is very limited. That is where paging comes in. Think of a page as in a book. You have the entire book (ROM/RAM chip), but you can only view it one page at a time. The z80 itself has no MMU, but the ASIC (You can look it up here) that TI designed lets it change the pages for all addresses, with each page letting you access 16KB chunks of the RAM/ROM chip.

The ASIC lets you set the page in each bank (bank being the 4 16KB memory sections). Banks 1 and 2 (0x4000 and 0x8000) let you specify either RAM or ROM since the ASIC routes everything itself. These banks are just small windows that let you directly access the RAM/ROM.

Now, reading up at the paging ports question about RAM being at 0x80, you need to look at it from a binary perspective. You specify the page that you want mapped using 7 bits, or 0b-XXXXXXX. If you want page 5 of the ROM, you write 0b00000101 to the paging port. Well, I did say 7 bits, so what does bit 8 do? If that bit is 0, like 0b0xxxxxxx, then you are selecting a page in ROM. If it is 1 (0b1xxxxxxx), then you are selecting in the RAM. So when people say RAM page 0x80, they mean page 0 of the RAM.

If you need anything else explained, ask away.
jammasterz wrote:
Tari wrote:
In general the mapping of pages to physical memory is that the high bit indicates Flash or RAM. That is, page 0 is the beginning of Flash and page 0x80 is the beginning of RAM.
So the full adress is actually 3 bytes, the page, and then the 2 byte adress withing the page?

That's a good way to think of it, yes. You can take the current page mapping, prepend the active page mapping for the bank you're in, and that gives a logical address. Since there are four banks, only the low 14 bits of any given address are taken (since the top two specify the bank). We might use the following pseudocoded procedure to convert a physical address to a logical address.

Code:
function physical2logical(phys) {
    bank := (phys & 0xC000) >> 14
    phys &= 0x3FFF
    return (pageForBank(bank) << 14)) | phys
}
pageForBank is always 0 for bank 0, and a lookup in the corresponding port for the other banks.

With that logical addressing scheme on an 84+ SE with the full 8 pages of RAM, we could say that RAM exists in the logical address range 0x200000-0x217FFFF, and Flash is 0x000000-0x1FFFFF.

Rather interestingly, this is similar to how the TI-86 OS does addressing. It doesn't have any user archive, but there are a number of RAM pages. Romcalls that work on user data (in RAM, possibly on any page) take (and return) 24-bit addresses in register pseudotriples AHL and BDE.
Thanks everybody, i think i understand it all now Smile.
jammasterz wrote:
Thanks everybody, i think i understand it all now Smile.
Great to hear. Please don't hesitate to ask us any additional questions that you might come up with on a longer-term pondering of our explanations.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement