insert_kernel_ram_calls.hss 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. [Main]
  2. Title=__ld_insert_kernel_ram_calls
  3. [Top]
  4. __ld_insert_kernel_ram_calls can be used to handle
  5. <A HREF="$$LINK(symbols_ram_call)">RAM calls</A>. It inserts references to
  6. RAM calls in the format used by kernels:
  7. <UL>
  8. <LI>If the program uses at least one RAM call...
  9. <UL>
  10. <LI><B>2 bytes:</B> the number of different RAM calls minus 1</LI>
  11. <LI>For each RAM call...
  12. <UL>
  13. <LI><B>2 bytes:</B> RAM call information:
  14. <UL>
  15. <LI>Bits 0 through 13: <I>index</I></LI>
  16. <LI>Bit 14: <I>type</I>
  17. (0: <A HREF="$$LINK(symbols_ram_call)">RAM call</A>;
  18. 1: <A HREF="$$LINK(symbols_extra_ram_addr)">extra RAM
  19. address</A>)</LI>
  20. <LI>Bit 15: <I>size</I> (0: 4 bytes; 1: 2 bytes)</LI>
  21. </UL></LI>
  22. <LI>Relocation table for this RAM call:
  23. <UL>
  24. <LI>For each reference...
  25. <UL>
  26. <LI><B>2 bytes:</B> <I>location</I> (may not be 0)</LI>
  27. </UL></LI>
  28. <LI><B>2 bytes:</B> 0</LI>
  29. </UL></LI>
  30. </UL></LI>
  31. </UL></LI>
  32. </UL>
  33. If a program uses this insertion, it must process it as follows:
  34. <UL>
  35. <LI>For each RAM call...
  36. <UL>
  37. <LI>For each relocation entry...
  38. <UL>
  39. <LI>Get the starting address of the program (via
  40. <A HREF="$$LINK(symbols_ld_entry_point)">__ld_entry_point</A>);</LI>
  41. <LI>Add the <I>location</I> value;</LI>
  42. <LI>Modify the value (<I>offset</I>) at the resulting address (2 or
  43. 4 bytes depending on <I>size</I>):
  44. <UL>
  45. <LI>If <I>type</I> indicates an extra RAM address:
  46. <UL>
  47. <LI>Determine the location of the extra RAM table row indexed
  48. by <I>index</I> (see
  49. <A HREF="$$LINK(symbols_extraram)">_extraram</A>);</LI>
  50. <LI>Get the correct value for the current calculator from
  51. this row;</LI>
  52. </UL>
  53. Else:
  54. <UL>
  55. <LI>Get the address/value of the RAM function/variable
  56. indexed by <I>index</I>;</LI>
  57. </UL></LI>
  58. <LI>Add the value of <I>offset</I>;</LI>
  59. <LI>Write the resulting address/value to the space covered by
  60. <I>offset</I>.</LI>
  61. </UL></LI>
  62. </UL></LI>
  63. </UL></LI>
  64. </UL>
  65. Before program termination, this process has to be reverted, so that it can
  66. be repeated the next time the program starts. Simply deactivating the
  67. relocation code would prevent programs from being transferred between
  68. devices.