Re: [cc65]Asm in CC65

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2001-01-07 22:18:37


On Sun, Jan 07, 2001 at 04:13:49PM -0500, troy silvey wrote:
> Can you explain this to me with an example maybe.

No problem. To insert CLI and SEI instructions in your code you may, for
example, use the following macros:

	#define CLI()	__asm__ ("\tcli");
	#define SEI()	__asm__ ("\tsei");

To protect the increment of a variable (maybe because it's a word variable
that's also accessed by an interrupt handler), using these macros:

	SEI();
	++counter;
	CLI();

Some of the header files do contain macros that expand to inline assembler,
you may want to have a look at them. Examples are:

	6502.h
	ctype.h

Using inline assembler may give problems with the optimizer, so please follow
these rules:

  * Always use a separate assembler module if possible. This avoids all
    problems but the assembler code may not be inlined.

  * Be careful not to write to any zero page locations used by the compiler.

  * Be sure to use the same syntax as generated by the compiler. Use lower
    case, with a tab before the mnemonic and a tab between mnemonic and
    operand. Prefer hexadecimal notation for immidiate operands.

The asm syntax will probably change for the next release, because the current
syntax is not flexible enough. Apart from that, the input should get preparsed
by the compiler to adjust it to the format expected by the backend.

Regards


	Uz


--
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:38 CET