Recent

Author Topic: Crosscompiler  (Read 1624 times)

julkas

  • Guest
Crosscompiler
« on: September 26, 2019, 07:31:12 pm »
All tutorials about avr crosscompiler begin with - "Make sure you are running up-to-date Trunk versions of both FreePascal and Lazarus...".
I have generated FPC 3.3.1 for my Arduino using FPC 3.0.4.
So, what is the real difference?

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Crosscompiler
« Reply #1 on: September 26, 2019, 07:54:54 pm »
You did just right, I also build all my trunk based crosscompilers with fpc 3.0.4

You need the resulting crosscompiler to be from trunk so that you get all the improvements and fixes that ccrause and others contributed.
You will need Lazarus trunk if you plan to use debugging with a gdbserver, if using serial console is enough for you then most likely the version of lazarus does not matter much.

MiR

ccrause

  • Hero Member
  • *****
  • Posts: 1007
Re: Crosscompiler
« Reply #2 on: September 27, 2019, 03:08:44 pm »
All tutorials about avr crosscompiler begin with - "Make sure you are running up-to-date Trunk versions of both FreePascal and Lazarus...".
I have generated FPC 3.3.1 for my Arduino using FPC 3.0.4.
So, what is the real difference?
An interesting question.  I extracted all FPC issues from the bug tracker and filtered it for all issues marked as fixed in version 3.1.1 or 3.3.1 and containing avr.  The resulting list should be most of the issues/features implemented since 3.0.4 was released:

Issue ID | Summary
33170 | AVR: CLR in ISR corrupts SREG
36066 | AVR - Incorrect code generated when copying a static array [patch]
36051 | AVR - avrsim doesn't always return correct exit code
35752 | Creating avr crosscompiler stops building rtl
35899 | AVR [patch] Enable nostackframe directive for interrupt routines
35691 | AVR [patch] div, mod and shift operations for 64 bit math
33914 | AVR - invalid address used when evaluating a variable in gdb
35332 | AVR - incorrect stack error checking
32103 | AVR - Assembler routines for 8, 16 & 32 bit unsigned div (code contribution)
35072 | AVR embedded - wrong Linker parameters when space in path
33952 | AVR, output string corrupt if compiled with optimization level -O2.
34721 | AVR - 16 bit timer registers needs to be written high byte first
34317 | AVR - Getting rid of nuisance warning for interrupt
33423 | AVR: if with bitpacked record creates uncomplete code
32071 | avr: inefficient code: 32 bit – compares in set operations
33417 | AVR: Bitpacked record inefficent evaluation
33322 | AVR - Negate operation of 8 bit variable not correct
33227 | AVR [patch] More descriptive error message when BRxx destination out of reach
32039 | AVR inline assembler does not accept a complemented argument
33202 | AVR - constant value in assembler code sometimes mangled by typecast
32007 | AVR - link error when compiling assembler code with incorrect register specified for sbiw
33189 | AVR - [feature patch] Update subarch once controller option is read
32261 | AVR - invalid assembler instruction compiles when it shouldn't
32946 | AVR - assembler parser incorrectly coverts a negative const to unsigned const
33191 | AVR - [feature patch] Add controller name as system acro
33192 | AVR - [patch] Incorrect subarch for atmega8, 8A, 16, 32
33165 | R1 has no valid value in ISR routine
32915 | AVR - internal error compiling assembler code that references a field of a record parameter
30287 | revision 33931 breaks building cross-compilers for avr-embedded and m68k-linux on x86_64-darwin
32109 | AVR - compiler raises exception when encountering a branch instruction with absolute value
32949 | AVR - BREQ instruction in asm block modified by compiler
33098 | AVR - LDS assembler instruction with absolute address gives compiler error
33086 | AVR - assembler with address reference with 0 displacement passes wrong assembler instructions to avr-gas [patch]
32821 | AVR - invalid assembler generated for variable at absolute 0
32839 | AVR - at90pwm161 subarch type incorrect - patch
29758 | Invalid(?) assembler generated to reference a procedure parameter on AVR
32072 | avr:  appending a character to a string does not work.
32686 | ppcrossavr errors in handling CHARs
32195 | Internal error 2011082401 on use of .byte or .word etc. in inline asm
32150 | AVR - assembler instruction ST requires pointer register (X, Y or Z) but FPC changes this to normal register name
32633 | AVR - code modification suggestion for _FPC_haltproc and Default_IRQ_handler loops
32040 | AVR inline assembler: functions lo8 and hi8 work incorrectly
32043 | AVR inline assembler: incorrect evaluation of 16 bit constants
32474 | absolute interleaved with memory access
31925 | revision 36342 breaks building avr-embedded avr25 and avr35
32418 | revision 37182 breaks cross building avr-embedded
32016 | AVR inline assembler incorrectly assembles LD, LDD, ST, STD opcodes

julkas

  • Guest
Re: Crosscompiler
« Reply #3 on: September 27, 2019, 03:52:44 pm »
Quick check for 32040 - AVR inline assembler: functions lo8 and hi8 work incorrectly
Pascal source -
Code: Pascal  [Select][+][-]
  1. program b32040;
  2. const
  3.   c0 = 0;
  4.   c1 = 1;
  5.   c2 = $02;
  6.   c10 = $10;
  7.   c22 = $22;
  8.   c100 = $100;
  9.   c1000 = $1000;
  10.   c3070 = $3070;
  11.  
  12. procedure something; assembler; nostackframe;
  13. asm
  14.   ldi ZL, lo8(c0);
  15.   ldi ZH, hi8(c0);
  16.   ldi ZL, lo8(c1);
  17.   ldi ZH, hi8(c1);
  18.   ldi ZL, lo8(c2);
  19.   ldi ZH, hi8(c2);
  20.   ldi ZL, lo8(c10);
  21.   ldi ZH, hi8(c10);
  22.   ldi ZL, lo8(c22);
  23.   ldi ZH, hi8(c22);
  24.   ldi ZL, lo8(c100);
  25.   ldi ZH, hi8(c100);
  26.   ldi ZL, lo8(c1000);
  27.   ldi ZH, hi8(c1000);
  28.   ldi ZL, lo8(c3070);
  29.   ldi ZH, hi8(c3070);
  30.   ldi ZL, lo8(0x3070);
  31.   ldi ZH, hi8(0x3070);
  32.   ldi ZL, lo8(0x300);
  33.   ldi ZH, hi8(0x300);
  34. end;
  35.  
  36. begin
  37. end.
Generated assembly -
Code: ASM  [Select][+][-]
  1.         .file "b32040.pas"
  2. # Begin asmlist al_pure_assembler
  3.  
  4. .section .text.n_psb32040_ss_something
  5. .globl  PsB32040_ss_SOMETHING
  6. PsB32040_ss_SOMETHING:
  7. .Lc2:
  8. #  CPU AVR5
  9.         ldi     r30,lo8(0)
  10.         ldi     r31,hi8(0)
  11.         ldi     r30,lo8(1)
  12.         ldi     r31,hi8(1)
  13.         ldi     r30,lo8(2)
  14.         ldi     r31,hi8(2)
  15.         ldi     r30,lo8(16)
  16.         ldi     r31,hi8(16)
  17.         ldi     r30,lo8(34)
  18.         ldi     r31,hi8(34)
  19.         ldi     r30,lo8(256)
  20.         ldi     r31,hi8(256)
  21.         ldi     r30,lo8(4096)
  22.         ldi     r31,hi8(4096)
  23.         ldi     r30,lo8(12400)
  24.         ldi     r31,hi8(12400)
  25.         ldi     r30,lo8(12400)
  26.         ldi     r31,hi8(12400)
  27.         ldi     r30,lo8(768)
  28.         ldi     r31,hi8(768)
  29. #  CPU AVR5
  30.         ret
  31. .Lc1:
  32. .Le0:
  33.         .size   PsB32040_ss_SOMETHING, .Le0 - PsB32040_ss_SOMETHING
  34. # End asmlist al_pure_assembler
  35. # Begin asmlist al_procedures
  36.  
  37. .section .text.n_main
  38. .globl  main
  39. main:
  40. .globl  PASCALMAIN
  41. PASCALMAIN:
  42. .Lc4:
  43. .Lc5:
  44.         call    FPC_INIT_FUNC_TABLE
  45.         call    fpc_do_exit
  46. .Lc3:
  47. .Le1:
  48.         .size   main, .Le1 - main
  49.  
  50. .section .text.n_FPC_INIT_FUNC_TABLE
  51. .globl  FPC_INIT_FUNC_TABLE
  52. FPC_INIT_FUNC_TABLE:
  53.         ret
  54.  
  55. .section .text.n_FPC_FINALIZE_FUNC_TABLE
  56. .globl  FPC_FINALIZE_FUNC_TABLE
  57. FPC_FINALIZE_FUNC_TABLE:
  58.         ret
  59. # End asmlist al_procedures
  60. # Begin asmlist al_globals
  61.  
  62. .section .data.n_INITFINAL
  63.         .balign 2
  64. .globl  INITFINAL
  65. INITFINAL:
  66.         .byte   0,0
  67. .Le2:
  68.         .size   INITFINAL, .Le2 - INITFINAL
  69.  
  70. .section .data.n_FPC_THREADVARTABLES
  71.         .balign 2
  72. .globl  FPC_THREADVARTABLES
  73. FPC_THREADVARTABLES:
  74.         .long   0
  75. .Le3:
  76.         .size   FPC_THREADVARTABLES, .Le3 - FPC_THREADVARTABLES
  77.  
  78. .section .data.n_FPC_RESOURCESTRINGTABLES
  79.         .balign 2
  80. .globl  FPC_RESOURCESTRINGTABLES
  81. FPC_RESOURCESTRINGTABLES:
  82.         .short  0
  83. .Le4:
  84.         .size   FPC_RESOURCESTRINGTABLES, .Le4 - FPC_RESOURCESTRINGTABLES
  85.  
  86. .section .data.n_FPC_WIDEINITTABLES
  87.         .balign 2
  88. .globl  FPC_WIDEINITTABLES
  89. FPC_WIDEINITTABLES:
  90.         .short  0
  91. .Le5:
  92.         .size   FPC_WIDEINITTABLES, .Le5 - FPC_WIDEINITTABLES
  93.  
  94. .section .data.n_FPC_RESSTRINITTABLES
  95.         .balign 2
  96. .globl  FPC_RESSTRINITTABLES
  97. FPC_RESSTRINITTABLES:
  98.         .short  0
  99. .Le6:
  100.         .size   FPC_RESSTRINITTABLES, .Le6 - FPC_RESSTRINITTABLES
  101.  
  102. .section .fpc.n_version
  103. __fpc_ident:
  104.         .ascii  "FPC 3.3.1 [2019/09/22] for avr - embedded"
  105. .Le7:
  106.         .size   __fpc_ident, .Le7 - __fpc_ident
  107.  
  108. .section .data.n___stklen
  109.         .balign 2
  110. .globl  __stklen
  111. __stklen:
  112.         .short  1024
  113. .Le8:
  114.         .size   __stklen, .Le8 - __stklen
  115.  
  116. .section .data.n___heapsize
  117.         .balign 2
  118. .globl  __heapsize
  119. __heapsize:
  120.         .short  128
  121. .Le9:
  122.         .size   __heapsize, .Le9 - __heapsize
  123.  
  124. .section .bss.n___fpc_initialheap
  125.         .globl __fpc_initialheap
  126.         .size __fpc_initialheap,128
  127. __fpc_initialheap:
  128.         .zero 128
  129.  
  130. .section .data.n___fpc_valgrind
  131.         .balign 2
  132. .globl  __fpc_valgrind
  133. __fpc_valgrind:
  134.         .byte   0
  135. .Le10:
  136.         .size   __fpc_valgrind, .Le10 - __fpc_valgrind
  137. # End asmlist al_globals
  138. # Begin asmlist al_dwarf_frame
  139.  
  140. .section .debug_frame
  141. .Lc6:
  142.         .long   .Lc8-.Lc7
  143. .Lc7:
  144.         .long   -1
  145.         .byte   1
  146.         .byte   0
  147.         .uleb128        1
  148.         .sleb128        -4
  149.         .byte   24
  150.         .byte   12
  151.         .uleb128        13
  152.         .uleb128        1
  153.         .byte   5
  154.         .uleb128        24
  155.         .uleb128        0
  156.         .balign 4,0
  157. .Lc8:
  158.         .long   .Lc10-.Lc9
  159. .Lc9:
  160.         .short  .Lc6
  161.         .short  .Lc2
  162.         .short  .Lc1-.Lc2
  163.         .balign 4,0
  164. .Lc10:
  165.         .long   .Lc13-.Lc12
  166. .Lc12:
  167.         .short  .Lc6
  168.         .short  .Lc4
  169.         .short  .Lc3-.Lc4
  170.         .byte   4
  171.         .long   .Lc5-.Lc4
  172.         .byte   7
  173.         .uleb128        24
  174.         .balign 4,0
  175. .Lc13:
  176. # End asmlist al_dwarf_frame

 

TinyPortal © 2005-2018