Welcome, Guest. Please login or register.

Author Topic: compiling assembly.s files in gcc ... was: gcc wont compile with // comments?  (Read 13533 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: gcc wont compile with // comments?
« on: November 18, 2003, 12:56:03 AM »
Why not try to compile your C in C++ mode? A good C program is usually a C++ program too. C that doesn't compile in C++ mode often makes use of dodgy stuff like implicit casting from void* and so on.

I usually tend to compile C stuff in C++ mode as I prefer C++'s stricter enforcemnt of the language rules anyway.

If you want to do C99 stuff, vbcc also supports a few of the C99 extensions.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: gcc wont compile with // comments?
« Reply #1 on: November 18, 2003, 03:13:03 AM »
I hear ya buddy. Whilst I rate it as a compiler, I utterly *despise* gcc as a piece of software viewed from a user perspective.

I am not stupid and would regard myself a competent C/C++ programmer. Even my asm isn't too dreadful. So why is it I have *never* got it set up correctly without at least 5 attempts!

To anybody working with / maintaining the  amiga gcc port(s): For the love of God, please create a proper installer!
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: gcc wont compile with // comments?
« Reply #2 on: November 18, 2003, 03:35:31 PM »
Don't try that bollocks with me, sir. I have a zero tolerence rating for such terminology. Users of non-words like 'l337' and 'w00t' should all be lined up against a wall and shot...

..yes, I am kidding :-)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: gcc wont compile with // comments?
« Reply #3 on: November 20, 2003, 01:05:49 AM »
Hey dude, is that the golded demo on their site or another one?
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: gcc wont compile with // comments?
« Reply #4 on: November 20, 2003, 01:24:19 AM »
Hmm, thats the one I already got. IIRC the installer skipped gcc saying it wasnt included for size reasons...Better have a closer look at it :lol:

-edit-

Just did - the one I had was 14Mb compressed so not the same at all :-)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: compiling assembly.s files in gcc was: gcc wont compile with // comments?
« Reply #5 on: December 09, 2009, 01:36:44 PM »
Quote from: NovaCoder;533113
To continue this old thread....

(snip)

Anyone got any ideas?


I got around all my C++ / asm combination problems by using inline C++ functions that call asm() construct directly.

For example
Code: [Select]

  inline uint32 swap32(uint32 val)
  {
    if (__builtin_constant_p(val)) {
      val = val<<16 | val>>16;
      val = ((val&0x00FF00FF)<<8) | ((val&0xFF00FF00)>>8);
    } else {
      asm(
        &quot;rol.w #8, %0\n\t&quot;
        &quot;swap %0\n\t&quot;
        &quot;rol.w #8, %0&quot;
        : &quot;=d&quot;(val)
        : &quot;0&quot;(val)
        : &quot;cc&quot;
      );
    }
    return val;
  }


You can (and I have) used the asm() statement inside an inline C++ function to jsr to an externally referenced function written in assembler. Just make sure the variables passed to your inline function are loaded into the correct registers inside the asm() just before you jsr and add those registers to the clobber list so the compiler knows your call is going to trash them.
« Last Edit: December 09, 2009, 01:40:07 PM by Karlos »
int p; // A