 |
__ld_insert_kernel_ram_calls |
__ld_insert_kernel_ram_calls can be used to handle
RAM calls. It inserts references to
RAM calls in the format used by kernels:
- If the program uses at least one RAM call...
- 2 bytes: the number of different RAM calls minus 1
- For each RAM call...
- 2 bytes: RAM call information:
- Relocation table for this RAM call:
- For each reference...
- 2 bytes: location (may not be 0)
- 2 bytes: 0
If a program uses this insertion, it must process it as follows:
- For each RAM call...
- For each relocation entry...
- Get the starting address of the program (via
__ld_entry_point);
- Add the location value;
- Modify the value (offset) at the resulting address (2 or
4 bytes depending on size):
- If type indicates an extra RAM address:
- Determine the location of the extra RAM table row indexed
by index (see
_extraram);
- Get the correct value for the current calculator from
this row;
Else:
- Get the address/value of the RAM function/variable
indexed by index;
- Add the value of offset;
- Write the resulting address/value to the space covered by
offset.
Before program termination, this process has to be reverted, so that it can
be repeated the next time the program starts. Simply deactivating the
relocation code would prevent programs from being transferred between
devices.