public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: gcc & assembly coding conventions ??
@ 2003-09-11 18:58 Richard Sewards
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Sewards @ 2003-09-11 18:58 UTC (permalink / raw)
  To: garret.spears, gcc-help

Arguably, you should not be editing an assembler source file at all.  It
is possible to do everything using C and inline assembler, including CPU
startup code (I have done it for an 8240 boot ROM monitor).  Then you
can use #define, const, etc. and write most of your code in C.  I have
always found C + inline assembler to be easier to deal with than pure
assembler.

Regards,
--
Richard Sewards
richard.sewards@navtelcom.com

-----Original Message-----
From: garret.spears [mailto:garret.spears@comcast.net] 
Sent: Wednesday, September 10, 2003 4:07 PM
To: gcc-help@gcc.gnu.org
Subject: gcc & assembly coding conventions ??

Sorry to bother you with the following.  I have looked thru the gcc &
gas
manuals and I am coming up without any answers.
I haven't done this for many years, many years.  I am trying to write
assembly code for a coldfire processor.  Essentially when I did this
years
ago I dedicated a section to defines or equates, a section to data
space,
and a section to code - assembly language.
I may be confused on naming or identifying these sections now.
I am creating a file called foo.S and placing my sections into it.  So
far I
get errors saying the line "mbar equ 0x10000000" is not an instruction.
Is there a place that I should be going that will lead me thru the
correct
structure and declarations that I need to use?
Thanks  for your patience & help,
Garret


Refernce:
gcc-2.95.3 -m5200 -x assembler led.S

Led.S consists of the following first 20-30 lines

#DEFINE INIT_SECTION_ASM_OP  // is this a requird line or should ther be
another?

// Base addr of internal resources & SIM resources
MBAR    EQU    0x10000000                // alt I have seen ".set
MBAR=0x10000000" but the manual shows an EQU syntax
// Exception base addr to vector table
VBR     EQU     0x00000000
// Starting location of internal RAM & types of access
RAMBAR  EQU     0x30000000
//DRAM base address & permissions, $00000000
DRAM0   EQU     $0000

// System integration Module config register
SIMR       EQU      MBAR+$0003            // same problem here because
MBAR
is undefined
// Pin assignment register
PAR        EQU      MBAR+$00CB


Should I be using a dot h file for some of this and a dot s file for my
actual assembly coding?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gcc & assembly coding conventions ??
  2003-09-10 20:07 garret.spears
@ 2003-09-10 20:39 ` Nick Patavalis
  0 siblings, 0 replies; 3+ messages in thread
From: Nick Patavalis @ 2003-09-10 20:39 UTC (permalink / raw)
  To: gcc-help

On Wed, Sep 10, 2003 at 01:07:25PM -0700, garret.spears wrote:

> Refernce:
> gcc-2.95.3 -m5200 -x assembler led.S

Before you compile an assembly source file, you should decide whether
you want to pass it through the C preprocessor (CPP) or not. If you
decide to use the preprocessor then you should name your source-file
"something.S" (capital "S"); if not, then you should name it
"something.s" (lowcase "s"). Provided that you follow this convention
you don't *have* to specify the source-language explicitly using the
"-x <lang>" option; gcc can figure-it out from the filename
extension. If you don't want to or can't use this naming convention,
then "-x <lang>" is required:

   gcc-2.95.3 -m5200 asmcode.s -o asmcode.o
   gcc-2.95.3 -m5200 -x assembler asmcode.asm -o asmcode.o
   
   
     Compile without passing the source through CPP.

   gcc-2.95.3 -m5200 asmcode1.S -o asmcode1.o
   gcc-2.95.3 -m5200 -x assembler-with-cpp asmcode1.asm -o asmcode1.o

     Pass the source through CPP and then compile.

If you decide to pass your assembly through CPP, then (and only then)
you *can* use all the C preprocessor goodies, like "#define",
"#include", "#ifdef", etc. But remember: these are handled by the
preprocessor *not* the assmebler!

> 
> #DEFINE INIT_SECTION_ASM_OP  // is this a requird line or should ther be
> another?
>

This is neither required nor allowed! First: you're not using
"assembler-with-cpp" so #DEFINE has no sense! Second: Even if you used
it, CPP is CaSe-SeNsItIvE, so it should be "#define" and not "#DEFINE"
 
> // Base addr of internal resources & SIM resources
> MBAR    EQU    0x10000000                // alt I have seen ".set

What you should have said is (observe the dot!):

  MBAR    .EQU    0x10000000 

Which is the same as saying

  #define MBAR 0x10000000

> 
> Should I be using a dot h file for some of this and a dot s file for my
> actual assembly coding?
>

You can use ".h" files (and the respective "#include" directives) only
if you pass your assembly through CPP. You don't *have* to use them,
though!

> Essentially when I did this years
> ago I dedicated a section to defines or equates, a section to data space,
> and a section to code - assembly language.

data section:

 .data

     ... contents of the data-section ...

code section:

 .text

     ... contents of the text-section ...

or if you use an object-format that can support arbitrarily-named
sections:

  .section ".data"

     ... contents of the data-section ...

  .section ".text"

     ... contents of the text-section ...

You don't need a section for the "equ"s since they produce no output!

Hope this helps
/npat

-- 
As for systems that are not like Unix, such as MSDOS, Windows, the
Macintosh, VMS, and MVS, supporting them is usually so much work that
it is better if you don't.
  -- Richard Stallman "GNU Coding Standards"

^ permalink raw reply	[flat|nested] 3+ messages in thread

* gcc & assembly coding conventions ??
@ 2003-09-10 20:07 garret.spears
  2003-09-10 20:39 ` Nick Patavalis
  0 siblings, 1 reply; 3+ messages in thread
From: garret.spears @ 2003-09-10 20:07 UTC (permalink / raw)
  To: gcc-help

Sorry to bother you with the following.  I have looked thru the gcc & gas
manuals and I am coming up without any answers.
I haven't done this for many years, many years.  I am trying to write
assembly code for a coldfire processor.  Essentially when I did this years
ago I dedicated a section to defines or equates, a section to data space,
and a section to code - assembly language.
I may be confused on naming or identifying these sections now.
I am creating a file called foo.S and placing my sections into it.  So far I
get errors saying the line "mbar equ 0x10000000" is not an instruction.
Is there a place that I should be going that will lead me thru the correct
structure and declarations that I need to use?
Thanks  for your patience & help,
Garret


Refernce:
gcc-2.95.3 -m5200 -x assembler led.S

Led.S consists of the following first 20-30 lines

#DEFINE INIT_SECTION_ASM_OP  // is this a requird line or should ther be
another?

// Base addr of internal resources & SIM resources
MBAR    EQU    0x10000000                // alt I have seen ".set
MBAR=0x10000000" but the manual shows an EQU syntax
// Exception base addr to vector table
VBR     EQU     0x00000000
// Starting location of internal RAM & types of access
RAMBAR  EQU     0x30000000
//DRAM base address & permissions, $00000000
DRAM0   EQU     $0000

// System integration Module config register
SIMR       EQU      MBAR+$0003            // same problem here because MBAR
is undefined
// Pin assignment register
PAR        EQU      MBAR+$00CB


Should I be using a dot h file for some of this and a dot s file for my
actual assembly coding?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-09-11 18:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-11 18:58 gcc & assembly coding conventions ?? Richard Sewards
  -- strict thread matches above, loose matches on Subject: below --
2003-09-10 20:07 garret.spears
2003-09-10 20:39 ` Nick Patavalis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).