faq.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  2. <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
  3. <head>
  4. <title>Frequently Asked Questions - GTC documentation</title>
  5. <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
  6. <link rel='stylesheet' type='text/css' href='layout/default.css' />
  7. </head>
  8. <body>
  9. <p><a href='index.html'>◄ Back to index</a></p>
  10. <div class='c0'>
  11. <h1>Frequently Asked Questions</h1>
  12. <div class='toc'><div class='toctop'><div class='tocbot'><div class='toc-content'>
  13. <b>Contents:</b><ul>
  14. <li><a href='#Common.issues'>Common issues</a>
  15. <ul>
  16. <li><a href='#.28on-calc.29.I.keep.getting.errors.such.as..22not.enough.memory.to.compile.function.abc.22'>(on-calc) I keep getting errors such as "not enough memory to compile function abc"</a></li>
  17. </ul></li>
  18. <li><a href='#Differences.between.GTC.and.TIGCC'>Differences between GTC and TIGCC</a>
  19. <ul>
  20. <li><a href='#How.can.I.port.my.program.from.TIGCC.to.GTC.3f'>How can I port my program from TIGCC to GTC?</a></li>
  21. <li><a href='#How.can.I.make.sure.my.GTC.program.can.be.compiled.with.TIGCC.too.3f'>How can I make sure my GTC program can be compiled with TIGCC too?</a></li>
  22. </ul></li>
  23. </ul>
  24. </div></div></div></div>
  25. <div class='c1'>
  26. <hr class='hr1' /><h1 class='heading'><a name='Common.issues'></a>Common issues</h1><div class='c1in'><hr class='hr1in' /><div class='c2'>
  27. <hr class='hr2' /><h2 class='heading'><a name='.28on-calc.29.I.keep.getting.errors.such.as..22not.enough.memory.to.compile.function.abc.22'></a>(on-calc) I keep getting errors such as "<code>not enough memory to compile function <em>abc</em></code>"</h2><div class='c2in'><hr class='hr2in' />
  28. <p>This could be because you do not have enough free RAM (more than 100kb is recommended), but if you have enough RAM it is probably because the function <em>abc</em> is too large to fit in the memory of the calculator. You will need to split into smaller functions to avoid the error.</p>
  29. <p>Another reason could be that you have a<span class='widespace'>&#32;</span><a href='preprocessor.html#.23define'><code>#define</code></a><span class='widespace'>&#32;</span>with a large body, or a very
  30. large number of global declarations. This shouldn't be a problem for most
  31. programs, but if you think you are in this case, you can try to solve it with<span class='widespace'>&#32;</span><code>#undef</code><span class='widespace'>&#32;</span>or by creating a <a href='missing.html' class='invalidlink'>precompiled header</a>.</p>
  32. </div></div>
  33. </div></div>
  34. <div class='c1'>
  35. <hr class='hr1' /><h1 class='heading'><a name='Differences.between.GTC.and.TIGCC'></a>Differences between GTC and TIGCC</h1><div class='c1in'><hr class='hr1in' /><div class='c2'>
  36. <hr class='hr2' /><h2 class='heading'><a name='How.can.I.port.my.program.from.TIGCC.to.GTC.3f'></a>How can I port my program from TIGCC to GTC?</h2><div class='c2in'><hr class='hr2in' />
  37. <p>It all depends on what features your program uses. Here is a list of porting issues:</p>
  38. <ul><li> <b><code>long long</code><span class='widespace'>&#32;</span>support</b>: GTC does not support them, if you use them you will have to rewrite your code to use two<span class='widespace'>&#32;</span><code>long</code>s instead. In many cases it's very easy to port.
  39. </li><li> <b><code>asm()</code><span class='widespace'>&#32;</span>vs<span class='widespace'>&#32;</span><a href='extensions.html#asm.7b.7d.statement'><code>asm{}</code></a></b>: the assembly syntax is different between GTC and TIGCC. However if you are familiar with <a href='glossary.html#a68k'>a68k</a> you will be able to use GTC's syntax in no time.
  40. </li><li> <b><code>float</code>/<code>double</code><span class='widespace'>&#32;</span>support</b>: currently, GTC does not support floats. If your program uses floats, then unless you think you can get rid of them (e.g. if you are only using them for sines and cosines, you can use a pre-computed table instead), you're basically stuck and should definitely continue using TIGCC (unless you're willing to go down to the assembly level). Sorry.
  41. </li></ul>
  42. <p>Additionally, you may run into these little behaviour differences:</p>
  43. <ul><li> <b>Cast constructors</b>: currently, the following code
  44. <pre>
  45. int *f(int *dest,int x) {
  46. memcpy(dest,(int[4]){x,x+1,x+2},8);
  47. return dest;
  48. }
  49. </pre>
  50. is not accepted by GTC because the array constructed is not constant (<code>x</code><span class='widespace'>&#32;</span>is not known at compile time). But you can rewrite it to use a temporary array instead:
  51. <pre>
  52. int *f(int *dest,int x) {
  53. int temp[4] = {x,x+1,x+2};
  54. memcpy(dest,temp,8);
  55. return dest;
  56. }
  57. </pre>
  58. </li><li> <b>Calling convention</b>: by default, GTC uses the<span class='widespace'>&#32;</span><code><a href='specificities.html#Default.calling.convention..28regparm.29'>regparm</a>(2,1)</code><span class='widespace'>&#32;</span>convention, while TIGCC uses the<span class='widespace'>&#32;</span><a href='specificities.html#AMS.calling.convention..28stkparm.29'><code>stkparm</code></a><span class='widespace'>&#32;</span>convention. This is only a problem if you have written assembly functions yourself; in this case, you have to specify the calling convention you use in the prototype, e.g.:
  59. <pre>
  60. asm {
  61. upper_8_bits:
  62. move.b 4(a7),d0
  63. rts
  64. };
  65. char upper_8_bits(long x);
  66. </pre>
  67. would become
  68. <pre>
  69. asm {
  70. upper_8_bits:
  71. move.b 4(a7),d0
  72. rts
  73. };
  74. char upper_8_bits(long x) __attribute__((stkparm));
  75. </pre>
  76. </li></ul>
  77. <p>This list may not be exhaustive, but I will be happy to hear about any problems you might have that are not mentioned in this list.</p>
  78. </div></div>
  79. <div class='c2'>
  80. <hr class='hr2' /><h2 class='heading'><a name='How.can.I.make.sure.my.GTC.program.can.be.compiled.with.TIGCC.too.3f'></a>How can I make sure my GTC program can be compiled with TIGCC too?</h2><div class='c2in'><hr class='hr2in' />
  81. <p>You should not have much trouble compiling GTC programs with TIGCC as GTC was designed to introduce as few incompatibilities as possible. However, if you use low-level features like assembly you might run into some problems:</p>
  82. <ul><li> See if your program uses <a href='extensions.html#GTC-specific.extensions'>GTC-specific extensions</a>. For example, if you really need to use a short bit of assembly you can use conditional compilation to turn a GTC-only program like this one:
  83. <pre>
  84. asm {
  85. turn_calculator_off:
  86. trap #4
  87. rts
  88. };
  89. </pre>
  90. into this more portable program:
  91. <pre>
  92. #ifdef __GTC__
  93. /* assembly code using GTC's <a href='extensions.html#asm.7b.7d.statement'><code>asm{}</code></a> syntax */
  94. asm {
  95. turn_calculator_off:
  96. trap #4
  97. rts
  98. };
  99. #else
  100. /* assembly code using TIGCC's <code>asm()</code> syntax */
  101. asm("
  102. turn_calculator_off:
  103. trap #4
  104. rts
  105. ");
  106. #endif
  107. </pre>
  108. </li><li> The default calling convention is different, so if you define your own assembly functions and call them from C code make sure their prototypes are properly specified with<span class='widespace'>&#32;</span><a href='specificities.html#Default.calling.convention..28regparm.29'><code>regparm</code></a>.
  109. </li></ul></div></div>
  110. </div></div></div>
  111. </body>
  112. </html>