GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

C and PASCAL (or any other high-level languages) in here please

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
Orion_
Captain Atari
Captain Atari
Posts: 425
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Postby Orion_ » Thu Jan 17, 2019 10:45 am

I think I found a workaround with GCC 8
not the best solution, but still better than using the stack.
on a small loop I gain 5 HBL between VBCC and GCC 8 :D

Code: Select all

static inline void   SpriteDraw(s16 x, s16 y, u16 tile, u16 size)
{
   asm volatile
   (
      "move.w   %0,%%d0\n\t"
      "move.w   %1,%%d1\n\t"
      "move.w   %2,%%d2\n\t"
      "move.w   %3,%%d3\n\t"
      "jsr   SpriteDraw"
   :
   : "r"(x), "r"(y), "r"(tile), "r"(size)
   : "%d0", "%d1", "%d2", "%d3", "%a0", "cc", "memory"
   );
}
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB

User avatar
Orion_
Captain Atari
Captain Atari
Posts: 425
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Postby Orion_ » Thu Jan 17, 2019 5:36 pm

I have a problem with the linker I use (RLN from Atari Jaguar development tool)
It won't recognize uninitialized variables from objects files produced by GCC 8

So I'm trying to use GCC linker but I have a strange error that is not quite documented on google :/
The command line:

Code: Select all

m68k-atari-mint-ld -nostdlib -T link.txt -o prog.bin cartbase.o main.o Game.o md_scroll.o


the link script:

Code: Select all

SECTIONS
{
  . = 0x0;
  .text : { *(.text) }
  .data : { *(.data) }
  . = 0xFF0000;
  .bss : { *(.bss) }
}


The error:

Code: Select all

m68k-atari-mint-ld: the VMA of section %A must be 0x000000e40134b518, but actual value is 0x0000000000000000
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 802
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Postby mfro » Thu Jan 17, 2019 6:13 pm

Orion_ wrote:the link script:

Code: Select all

SECTIONS
{
  . = 0x0;
  .text : { *(.text) }
  .data : { *(.data) }
  . = 0xFF0000;
  .bss : { *(.bss) }
}


The error:

Code: Select all

m68k-atari-mint-ld: the VMA of section %A must be 0x000000e40134b518, but actual value is 0x0000000000000000


MiNT binaries are linked to 0xe4 - it appears to me this is in fact the intended error message and the rest is just garbage from an incomplete 64 bit adaption.

Do you really mean to link to 0x0? This does not work with the (default) output format a.out-mintprg.

It should work (I hope) when you change to another binary format:

Code: Select all

--oformat binary

User avatar
Orion_
Captain Atari
Captain Atari
Posts: 425
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Postby Orion_ » Thu Jan 17, 2019 6:55 pm

mfro wrote:It should work (I hope) when you change to another binary format:

Code: Select all

--oformat binary

It's working !! :D :cheers:

Damn, I gain 12 HBL just by switching from VBCC to GCC 8, and not counting that the binding to my asm functions are not optimized to the fullest (due to that fact I didn't find a way to directly assign function parameters to specific registers)
but the gain is still worth it !
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB

czietz
Hardware Guru
Hardware Guru
Posts: 984
Joined: Tue May 24, 2016 6:47 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Postby czietz » Thu Jan 17, 2019 8:10 pm

You could try local register variables, instead of the "move.w" in the "asm" block:
https://gcc.gnu.org/onlinedocs/gcc/Loca ... -Variables

Code: Select all

static inline void   SpriteDraw_II(s16 x, s16 y, u16 tile, u16 size)
{
   register s16 rx asm("d0") = x;
   register s16 ry asm("d1") = y;
   register s16 rtile asm("d2") = tile;
   register s16 rsize asm("d3") = size;
   asm volatile
   (
      "jsr   SpriteDraw"
   : "=r"(rx), "=r"(ry), "=r"(rtile), "=r"(rsize)
   : "r"(rx), "r"(ry), "r"(rtile), "r"(rsize)
   : "%a0", "cc", "memory"
   );
}


This seems to generate better code (avoiding the move.w) according to my experiments with Compiler Explorer: http://brownbot.mooo.com/z/XU6bC_

ThorstenOtto
Atari Super Hero
Atari Super Hero
Posts: 738
Joined: Sun Aug 03, 2014 5:54 pm

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Postby ThorstenOtto » Thu Jan 17, 2019 11:47 pm

Orion_ wrote:
mfro wrote:due to that fact I didn't find a way to directly assign function parameters to specific registers


For normal functions (ie. ones that are not inlined), there is no way in gcc to do so. For ones that are inlined, you shouldn't worry which registers are used, unless
you later call some external asm function with it (like in your small example above).

in that case, you could do something like

Code: Select all

register int x asm("d0");

Note that you have to explicitly use the register keyword in that case. Also, you should then rewrite your inline asm that calls the external function, otherwise for code like

Code: Select all

"move %0,%%d0"


gcc will assign an additional, temporary register for "%0".

Edit: damn, christian was faster ;)

User avatar
Orion_
Captain Atari
Captain Atari
Posts: 425
Joined: Sat Jan 10, 2004 12:20 pm
Location: France
Contact:

Re: GCC 7.3.0 for m68k / m68020-60 / m5475 (ColdFire)

Postby Orion_ » Fri Jan 18, 2019 9:07 am

czietz wrote:You could try local register variables, instead of the "move.w" in the "asm" block:
https://gcc.gnu.org/onlinedocs/gcc/Loca ... -Variables

Code: Select all

static inline void   SpriteDraw_II(s16 x, s16 y, u16 tile, u16 size)
{
   register s16 rx asm("d0") = x;
   register s16 ry asm("d1") = y;
   register s16 rtile asm("d2") = tile;
   register s16 rsize asm("d3") = size;
   asm volatile
   (
      "jsr   SpriteDraw"
   : "=r"(rx), "=r"(ry), "=r"(rtile), "=r"(rsize)
   : "r"(rx), "r"(ry), "r"(rtile), "r"(rsize)
   : "%a0", "cc", "memory"
   );
}


This seems to generate better code (avoiding the move.w) according to my experiments with Compiler Explorer: http://brownbot.mooo.com/z/XU6bC_

Thank you for this ! I searched for more than 2 hours on the GCC documentation the syntax to achieve this, but couldn't make it work.
I tried your syntax and it's working great ! the code generated is even better of course, gaining 2 more HBL :D
My retro games shop including Atari ST/Falcon/Firebee games ! -- Free Atari games/demos/tools -- Free Falcon demos/tools
Atari Mega STe 4MB + SD2SCSI 1GB + NOVA ET4000 + Pico PSU + Gotek HxC // Atari STe 2MB


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 3 guests