RE: [cc65] Inline / Macro Assembly - basic questions

Date view Thread view Subject view

From: Greg Long (cc65_at_maneuveringspeed.com)
Date: 2003-03-08 01:01:17


the one that is killing me is branching - could someone explain what I
am doing wrong for branching in inline assembly?  It chokes on my
labels.

For the game, we're still trying to decide, but we want it to be simple
and addictive for a first attempt :)


-----Original Message-----
From: owner-cc65_at_musoftware.de [mailto:owner-cc65_at_musoftware.de] On
Behalf Of Greg Long
Sent: Friday, March 07, 2003 4:40 AM
To: cc65_at_musoftware.de
Subject: [cc65] Inline / Macro Assembly - basic questions 


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.

----------------------------------------------------------------------
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-08 01:02:06 CET