David Oakley writes:
> I've been
> looking for some decent documentation on using the asm() facility in GCC,
> and not had much luck. Neither the GNU site or the GCC site seem to go any
> further than mentioning the "Assembler Instructions with C Expression
> Operands" section that Daniel found.

What exactly did you want to know?  That section and the "Constraints"
section it links to describe the syntax in as much detail as can be.
If you need to learn about M68K assembler, you should go to Motorola's
DragonBall web pages, which you can find via my page, which you can find
via the "Developer Assistance" page of Palm's DevZone.  (Motorola seems
to reorganize its web site on a weekly basis!)

To be sure, it's not much of a tutorial.  You can find some sample code
in the startup code in the prc-tools source, and here's a slightly non-
trivial little sample:

static __inline__ char *
in_strcpy (char *d, const char *s) {
  __asm__ ("0: move.b (%1)+,(%0)+; bne.s 0b" : : "a" (d), "a" (s) : "cc");
  return d;
  }

This is strcpy() in less bytes than it takes to call the systrap :-).
The `"a"'s say to put the parameters (s and d) into _a_ddress registers,
the %k notation refers to whichever register it chose for the corresponding
parameter, and the `0: ... 0b' local label notation is a feature of the
GNU assembler.  (The template string is just fed straight to the assembler,
so there's another manual you'll have to read.  :-))

    John

Reply via email to