Welcome, Guest. Please login or register.

Author Topic: compiling assembly.s files in gcc ... was: gcc wont compile with // comments?  (Read 13517 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 only replies by Karlos
Re: gcc wont compile with // comments?
« Reply #14 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 cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: gcc wont compile with // comments?
« Reply #15 on: November 20, 2003, 02:52:57 AM »
i'm getting closer. by examining other peoples source i can now properly declare/prototype functions that would, otherwise, use __asm. here it is

#ifdef __SASC
#   define SAVEDS       __saveds
#   define ASM          __asm
#   define REG(x,y)     register __##x y
#elif defined(__GNUC__)
#   define SAVEDS       __saveds
#   define ASM
#   define REG(x,y)     y __asm(#x)
#elif defined(_DCC)
#   define SAVEDS       __geta4
#   define ASM
#   define REG(x,y)     __##x y
#elif defined(__STORM__)
#   define SAVEDS       __saveds
#   define ASM
#   define REG(x,y)     register __##x y
#elif defined(__VBCC__)
#   define SAVEDS       __saveds
#   define ASM
#   define REG(x,y)     __reg(#x) y
#else
#   error   add #defines for your compiler...
#endif

if anyone understands, that is, i found it in the blitzquake source: amigacompiler.h, heh.

then you can proto your function thus:

static void ASM thefunction( REG(a1,UBYTE *), REG(a2,UBYTE *), REG(a6,struct Library *));



NEXT PROBLEM:

compiling assembler ("whatever.s") files in gcc (as) ... i get an error for EVERY line of assembler along the lines of:

 unknown operator -- statement: ASM STATEMENT

or

parse error -- ASM STATEMENT

and

rest of line ignored, first ignored character is '@'



anyone?

 

Offline Steady

Re: gcc wont compile with // comments?
« Reply #16 on: November 20, 2003, 01:48:46 PM »
If you have a pure assembler file, you need to use an assembler to compile separate object code to be linked later on. The gcc compiler is expecting C syntax, which is why the asm() stuff is needed in the C program.

Maybe gcc has an assembler option that will do the trick. I don't know and can't check because I ain't got it. Someone else should help with that.
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: gcc wont compile with // comments?
« Reply #17 on: November 20, 2003, 03:49:10 PM »
i knew somebody would say that.. gcc auto detects assembly files (extension *.s is the standard) and passes them over to it's own assembly compiler, "as". i've got "phxass" too but i cant get make to let me use it for some reason, bizzare.

NEXT!
 

Offline Steady

Re: gcc wont compile with // comments?
« Reply #18 on: November 20, 2003, 04:43:57 PM »
Which is why I said that there might be an option. Only offering up possibilities.
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
compiling assembly.s files in gcc was: gcc wont compile with // comments?
« Reply #19 on: November 20, 2003, 04:58:37 PM »
yer, well it starts off with something like "Assembler Output:" before giving me all the errors. i'm half way now to figuring phxass out now. though i suspect i need to use it for the intermidiate assempler->object for the gcc c compiled files also. though i wouldnt know how to do that either!
 

Offline ncafferkey

  • Sr. Member
  • ****
  • Join Date: Feb 2003
  • Posts: 387
    • Show only replies by ncafferkey
Re: compiling assembly.s files in gcc was: gcc wont compile with // comments?
« Reply #20 on: November 21, 2003, 02:12:34 AM »
I think the assembler format accepted by as is a bit different from that accepted by PhxAss. Also, the GNU linker needs a.out format object files as input, whereas PhxAss generates Amiga-native hunk format files. I don't know if there's any solution to this problem. Not accepting hunk files has been one of the main problems with Amiga GCC for a long time.

If you still have problems with comments, apparently gcc accepts C++ comments as long as -ansi or -traditional aren't used.
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: compiling assembly.s files in gcc was: gcc wont compile with // comments?
« Reply #21 on: November 21, 2003, 10:03:01 PM »
well, i havent got as far as the hunk stage, as i'm still stuck at the assembly.s file stage. i first thought it might have been a pedantic syntax error. e.g. not having the commands at the first tab, or having lower case instructions instead of uppercase. but that's about my limit of assembly knowledge! really.

my // comments are accepted by gcc330, which is what i'm using now
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: compiling assembly.s files in gcc was: gcc wont compile with // comments?
« Reply #22 on: November 22, 2003, 03:08:15 AM »
again, i'm lurching along one inch at a time. if i manually instruct phxass to compile a filename.s file then it's happy to do so. howevery i get a bunch of errors relating to FUNCDEF. from what i can gather i need a funcdef macro, well there's one in libraries.i thus

   FUNCDEF       MACRO
   _LVO\1       EQU   FUNC_CNT
   FUNC_CNT    SET   FUNC_CNT-6
   FUNC_CNT    EQU   LIB_USERDEF   
          ENDM

which doesnt do the job, phxass simply says "unkown directive" for each line.

my other problem is somehow getting phxass and gcc's make to coexist so i dont have to manually do each .s file. and i still don't know if there will be issues with phxass's outputs and gccs.
 

Offline NovaCoder

Re: compiling assembly.s files in gcc was: gcc wont compile with // comments?
« Reply #23 on: December 08, 2009, 09:48:43 PM »
To continue this old thread....

I'm having the same kind of issues as this guy was. In theory you should just be able to add assembler sources directly to a project in StormC V4 when using the gcc compiler but that doesn't work for me (or him).

So now I'm using PhxAss to compile the assembly files to object files and adding them to my StormC project. I then have to use a special header file declaration as follows:


Code:
#define REG(reg,arg) arg __asm(#reg)
 
void setVol (REG(d0, int vol));

This works great as long as the project is in plain C but if I want to create a C++ project I get linker errors (adding extern to function definition doesn't help).

Anyone got any ideas?
Life begins at 100 MIPS!


Nice Ports on AmiNet!
 

Offline x303

Re: compiling assembly.s files in gcc was: gcc wont compile with // comments?
« Reply #24 on: December 08, 2009, 10:04:19 PM »
Quote
#define REG(reg,arg) arg __asm(#reg)
I'm not sure if stormgcc (especially c++) like the __asm bit. It might work if you remove it.

x303 :D :D :D
« Last Edit: December 08, 2009, 10:17:53 PM by x303 »
 

Offline NovaCoder

Re: compiling assembly.s files in gcc was: gcc wont compile with // comments?
« Reply #25 on: December 09, 2009, 01:23:29 AM »
Nope, that gives a syntax error :(
Life begins at 100 MIPS!


Nice Ports on AmiNet!
 

Offline NovaCoder

Re: compiling assembly.s files in gcc was: gcc wont compile with // comments?
« Reply #26 on: December 09, 2009, 03:09:13 AM »
Update:  Seems to work with a 'simple' prototype

eg void setVol(int vol);
Life begins at 100 MIPS!


Nice Ports on AmiNet!
 


Offline unusedunused

  • Sr. Member
  • ****
  • Join Date: Nov 2005
  • Posts: 479
    • Show only replies by unusedunused
Quote from: cycloid;65544
is that right?

it's c code (adoom)

it says "parse error before /" on line 1 of every file.

yes i know // is c++ but it's also c99



If you want that the gcc assembler gas support C style defines and includes, you need name in makefile the filename extension a capital s.

so assembly.S should support in C comment syntax.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: compiling assembly.s files in gcc was: gcc wont compile with // comments?
« Reply #29 from previous page: 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