Post Reply 
Executing FOCAL programs from ROM vs. RAM
04-11-2019, 04:41 AM
Post: #2
RE: Executing FOCAL programs from ROM vs. RAM
(04-10-2019 10:09 PM)David Hayden Wrote:  Since RAM and ROM are accessed using different CPU instructions, it seems like the processor would need two different methods to read FOCAL instructions - one when the program is in RAM and another when it's in ROM. Is this true? If not, then how does it work?

Yes, it uses different ways to read user code instructions. One internal CPU flag (10) is used to tell if the program pointer is in ROM or RAM, which speeds up the decision.

RAM program bytes need slightly trickier decoding as it is a register address plus offset inside the register. A clever trick based on putting together an indirect jump based on that offset is used, but it is still slower than when running from ROM.

So the PC is really 17 bits.

Quote:And what about the FOCAL program pointer and return stack in registers a & b? They are 16 bits. I assume those are ROM addresses when executing from ROM but what about when executing from RAM?

Not all ROM addresses are possible for user code. The lower addresses are set aside for the internal ROMs, no user code exists in them. The 17 bit PC is compressed to 16 bits when stored on the stack, taking advantage of this. A compressed RAM address uses 12 bits in the return stack (plus a 0 upper nibble), a ROM address is 16 bits with a non-zero upper nibble.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Executing FOCAL programs from ROM vs. RAM - hth - 04-11-2019 04:41 AM



User(s) browsing this thread: 1 Guest(s)