6502.org
http://forum.6502.org/

[120] How to read/write memory larger than 64K
http://forum.6502.org/viewtopic.php?f=7&t=375
Page 1 of 1

Author:  NothingWu [ Wed Jul 04, 2001 12:30 am ]
Post subject:  [120.1] How to read/write memory larger than 64K

Maxinum memory address is FFFF in 6502,

How to read or write data over 64K?
Can I use 'far' or 'huge' to declare a variable or a pointer?

Author:  GARTHWILSON [ Thu Jul 05, 2001 4:18 am ]
Post subject:  [120.2] How to read/write memory larger than 64K

There are many ways to address larger memory spaces. One way would be to use a one-page section of the normal 64K address space as a window into another, usually larger space, like 1MB for example. In this particular case, the low eight bits of processor's address bus would also be the low eight bits for the larger space; but the upper twelve bits of the new, larger space would have to be stored in memory-mapped output registers that would feed the upper 12 address bits of the larger memory. Then every time the high eight bits of the processor's address bus point to that window to the larger memory, the larger memory is enabled instead of the direct-access memory in the main 64K. Obviously, storing the upper bits means a few more processor instructions, but it may be a good way to have a really large data space. (It's not as practical to use as a large program space.)

The possibility of using directives called "far" or "huge", if they exist, would come from a compiler you might use-- but the 6502 itself only has 16 address bits and will not multiplex them for more. Your compiler would then add the extra instructions to take care of the overhead details above to access the extension memory bus.

The 65816 (the 6502-family processor with a 16-bit A, X, and Y) has and data- and program-bank registers that facilitate access to 16MB of memory space for both data and program. The eight additional address bits are put on the data bus while phase 2 is low, leaving the phase-2-high time for the usual data-bus functions. An external 8-bit latch holds those extra address bits during the phase-2-high time. There are still 64K boundaries that are not totally transparent, but you can do a lot of things that are either impractical or impossible to do with the 6502. It also has added addressing modes that give four-byte machine-language instructions, consisting of an op code followed by three bytes (24 bits) of address operand.

Perhaps someone else would like to describe other ways to address more than 64K with a 6502. I have not looked into how the Apple II 1MB card worked, for example. I believe the 512KB RAM cartridge the Commodore 64 used to make the GEOS GUI work 10 to 100 times as fast actually used it like a fast-access disc, using DMA to shuttle the information to and from the main memory.

Edit, May 2014 (13 years later!): My code in PIC16 microcontrollers has been overflowing the first 2048-word program page into the second, and the mickeymousities of the program-memory page-select bits have caused an awful lot of bugs, and wasted an awful lot of my time. Doing this kind of thing on a 65xx system, for data only, with only part of the memory map being a window into a much larger memory space, might work fine; but I sure wouldn't want to duplicate the PIC's problems. What a rotten design!

Garth

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/