[Coco] CCASM procedures

Robert Gault robert.gault at worldnet.att.net
Thu Dec 9 06:59:53 EST 2004


Roger Taylor wrote:
><snip>
> 
> The only drawback is that registers U and S are reserved within the 
> procedure.  S is the base to the parameters on the S stack, and U is the 
> base to the optional local memory (on the same S stack).  However, no 
> parameters or local memory are required for a procedure (there's a JSR 
> instruction for doing that!)
> 
 ><snip>

Instead of passing the parameters in one or both of the stack registers, 
you might consider that this should all be done by CCASM. In other 
words, when CCASM reads a section of code defined as a "proc", it should 
store in its own memory the variables and apply them within the 
procedure as the source code calls procs. The assembled program won't 
know or see this and all registers in a proc will behave in a normal 
fashion.

Here is a rough example which requires a reserved "word" to indicate a 
variable. I'm not sure what is left free in CCASM for a reserved word.

CLS	macro
	lda	\0
	ldx	\1
a@	sta	,x+
	cmpx	\1+$200
	bne	a@
	endm

	org	$7000
start	CLS	#$F8,#$400
	lda	#$E5
	sta	$F8
	CLS	$F8,#$400
	end

CCASM would compile the above as:

	org	$7000
start	lda	#$F8
	ldx	#$400
a@	sta	,x+
	cmpx	#$600
	bne	a@
	lda	#$E5
	sta	$F8
	lda	$F8
	ldx	#$400
a@	sta	,x+
	cmpx	#$600
	bne	a@
	end

The variables have been used for both numbers and memory locations. The 
proc should also be made accessable with the equivalent of an INCLUDE call.



More information about the Coco mailing list