[cc65] Inline / Macro Assembly - basic questions

Date view Thread view Subject view

From: Greg Long (greg_at_maneuveringspeed.com)
Date: 2003-03-07 13:40:14


After reading sec 8 - Inline Assembler:


Are labels not permitted in inline assembly for branching?

I can use variables from my C code with %v (None in this example) but
they have to be global - declared outside of main() - not declared in
this function.

The exception to the above would be using a stack offset %o, but that
would require some careful knowledge of where on the stack the variable
is, or would supplying the variable name allow the compiler to figure
that out?


"The builtin inline assembler is not a replacement for the full blown
macro assembler which comes with the compiler."  Understandable...the
advantage I see of inline is the ability to use variables from my C
code.

Greg


void InlineAssemblyTest()
{
	//a variable declared here could not be
	//used in my inline assy code?
	int test_variable = 4096;

	//clears the commodore screen as a test
	asm("			lda #0		");
	asm("			sta $fb		");
	asm("			lda #4		");
	asm("			sta $fc		");
	asm("			ldy #0		");
	asm("			lda #32		");
	asm("clrtstlp:	sta ($fb),y		");
	asm("			iny			");
	asm("			bcc clrtest2	");
	asm("			inc $fc		");
	asm{"clrtest2:	cpy #232		");
	asm{"			bne clrtstlp	");
	asm{"			ldx $fc		");
	asm{"			cpx #7		");
	asm{"			bne clrtstlp	");
}

----------------------------------------------------------------------
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 : 2003-03-07 13:41:12 CET