When you use the external memory bus of the 87K22, you connect it up to a regular 16-bit parallel flash device and the operation is totally transparent to the program. Program code < 128K uses the internal flash, and addresses above that go to the external memory chip... up to 2M bytes

Assuming that the compiler doesn't have any internal program size limits, there's nothing special you have to do when writing your program... you just end up with a really big hex file.

There are some limits/things to note:

- external memory is slower, so you have to reduce the system clock. The only reference I've found in the 87K22 datasheet is a note that says"Fmax=25MHz in 8-bit external memory mode". Using a 16-bit wide memory may ease this a bit, but there's nothing in the data sheet to back that up.

- you'll likely have to have a bootloader that can program both the internal and external flash devices since the regular ICSP programming tools like the pickit won't work to program the external flash.

- likewise, you can't use the ICD debugging tools, and the MPLAB simulator doesn't support the EMI either.

- there's an errata w/the 87K22 for the EMB. The CE chip select pin won't be extended if you use wait states, so you have to make sure the flash is fast enough to run in a single cycle.