Normally you would view a particular page of NVEM as comprising one or more separate tables of data. Each table will consist of several records. A record is like a row in a spreadsheet, and may contain one or more entries. Each entry can be a single byte, a floating point number, a pointer or a text string. A pointer is a 16 bit value that can represent the address of a record in a different table (allowing tables to point into tables, which is getting quite sophisticated!). Text entries can be of fixed length or varying length (which is where tables of pointers come in).
Here is a simple table:
| 1 |
| 4 |
| 9 |
| 16 |
If we assume these are byte values, we have here a table with 4 records, each consisting of a 1-byte entry.
Here is a more complicated table:
| 1 | 1.00000 |
| 4 | 1.41421 |
| 9 | 1.73205 |
| 16 | 2.00000 |
Each row (record) in this table consists of a byte value and a floating point value. (You may notice that for a number n in the range 1 to 4, the n'th row contains the square and the square root of n.). Because floating point numbers in SPLat take up 4 bytes, each record in this table is 5 bytes long.
Now, in your program you may use several such tables, each with a different number of bytes per entry. These tables will be stored sequentially in NVEM memory (how that happens you will find out about later). In order to access a given entry in a particular record within a specific table your program needs to know the following:
The majority of NVEM reads (and writes) therefore calculate the effective address within the NVEM page from the following formula:
Address = Pointer + (RecNum * RecLen) + InstructionOffset + IndexOffset
The IndexOffset is for the indexed mode (of those instructions that support it). It is equal to the number in the index register for byte transfer instructions, and 4 times the number in the index register for floating point transfer instructions.
The number of bytes of data read or written is implied by the instruction itself. There are instructions for accessing single bytes, instructions for accessing pointer values (2 bytes) and instructions accessing floating point numbers (4 bytes). There are also instructions for transferring whole records between RAM and NVEM and between the UV registers (see SPLat expansion framework) and NVEM. There is also a special instruction for transferring text directly from NVEM to the onboard LCD.