I've been screwing around with the 8051 microcontroller recently and I was just wondering if it's possible to somehow raise the size of the PC register since it can only support up to a 64k executable. |
Technically.... it can only address 64K or memory. There's a difference.
For example... the NES had this same limitation and it overcame it by putting swapping hardware on the cartridge. IE: "pages" or "banks" of the program could be swapped out and replaced with different banks.
So while you can't really modify the register itself to make it larger... you
can alter the memory mapping behavior so reads can address a larger executable. It'll typically involve some additional logic to transform the Address lines on the bus as well as an additional register.
EDIT: Apparently you ninja'd me with a question asking about what I just mentioned.
NES carts had additional hardware that monitored the address lines on the bus and filtered/changed them before passing it to the memory chip to actually fetch the memory.
Mapper 7 (AxROM) was a simple example of this. It had one additional register used to select a bank.
ROM is typically accessed via addresses $8000-FFFF. AxROM "swapped out" the memory in 32K blocks. So depending on which bank was swapped in, you'd get different results when reading.
IE reading $8000 would get you the below byte in memory depending on the currently selected bank:
Page 0: ROM[0x00000]
Page 1: ROM[0x08000]
Page 2: ROM[0x10000]
Page 3: ROM[0x18000]
... etc
this was accomplished simply by taking the address bits, masking out the high bit, and replacing it with the contents of the page select register.
Pseudocode to give you the idea (of course, this would be done by hardware):
1 2 3 4 5
|
address = address_requested_by_cpu;
address &= 0x7FFF; // chop off the $8000 bit
address |= (page_select_register << 15); // replace upper bits with the selected page
return romchip[ address ];
|