Re: [cc65] adding assembler labels from c?

From: Oliver Schmidt <ol.sc1web.de>
Date: 2008-01-01 01:26:14
Hi Chris,

> I find that I need to do a tight loop in assembly within a function, but
> I don't seem to be able to insert an assembler label in a __asm__
> statement.

That's by design. The docs say: "Pseudo instructions (like .import,
.byte and so on) are not allowed, even if the ca65 assembler (which is
used to translate the generated assembler code) would accept them. The
builtin inline assembler is not a replacement for the full blown macro
assembler which comes with the compiler."

> Should I be doing this in pure assembler, or is there a way
> to do this that I'm not finding in the docs?

Hm, maybe it's not that obvious but at least the docs say: "%g -
Assembler name of a C label". Do it this way:

myloop:
  asm("...");
  asm("...");
  asm("bne %g", myloop);

In other words: Use a C label, not an assembly label.

BTW: The docs say: "Inline assembler statements are subject to all
optimizations done by the compiler. There is currently no way to
protect an inline assembler statement from being moved or removed
completely by the optimizer. If in doubt, check the generated
assembler output, or disable optimizations." Tak that seriously. Do it
this way:

#pragma optimize(push, off)
void foo(void)
{
  ...
  asm("...");
  ...
}
#pragma optimize(pop)

Best, Oliver
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Jan 1 01:26:33 2008

This archive was generated by hypermail 2.1.8 : 2008-01-01 01:26:45 CET