P ROGRAMMING M ODEL : Acessing LatticeMico8 Memory Regions42 LatticeMico8 Processor Reference ManualAcessing LatticeMico8 Memory RegionsAs explained in "“Memory Regions” on page 5, the LatticeMico8 architecturedefines three distinct memory regions - PROM, Scratchpad, and Peripheral (I/O).ScratchpadThe LatticeMico8 Scratchpad can be read from (or written to) usingLatticeMico8 instructions - lsp, lspi, ssp, and sspi - regardless of whether it isinternal or external to the microcontroller. The developer should note that theLatticeMico8 compiler always defaults to the Scratchpad for its data reads/writes. That is, all memory accesses are always implemented using theseinstructions unless otherwise stated.PeripheralThe LatticeMico8 Peripheral (I/O) region can be read from (or written to) usingLatticeMico8 instructions - import, importi, export, and exporti. The developershould note that the LatticeMico8 compiler does not use these instructions fordata reads/writes unless explicitly directed to do so. There are two ways inwhich the developer can instruct the compiler to use these instructions for aparticular data access:1. Inlined Assembly - The developer can access data using inlined assemblythat uses these instructions.2. Builtin Function - The LatticeMico8 compiler provides two "builtin"functions that can be used by the software developer in his code when heneeds to access an address within the Peripheral region. The functionsare shown in Table 12.NoteThe size and location of the LatticeMico8 Scratchpad is configurable. Thesoftware developer should note that MSB restricts the Scratchpad, regardlessof its size, to within 0x00000000 - 0x7FFFFFFF. Any MSB component thatfalls within this range, as well as, falls within the Scratchpad is accessed usingthe aforementioned LatticeMico8 instructions.Table 12: Builtin FunctionsFunction Effectvoid __builtin_export (char value, size_t address) Generates an export or exporti instruction