[Coco] CCASM procedures

Roger Taylor rtaylor at bayou.com
Thu Dec 9 00:38:52 EST 2004


At 04:45 AM 12/8/2004, you wrote:

>Looks simple and effective. Good work!

I've improved upon it.  I really like it now.

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!)

I've added a var psuedo-op which computes the offsets and total local 
memory the procedure will need.  You can still use any other code, even 
static memory-reserving psuedo-ops like RMB, etc.

The following sample procedure is working great.  Actually, the CALL 
function destroys registers D, X, and Y at this time (I'm working on this 
right now).

         org     3584

Asub    proc    address:word,data:byte
local   var     256             reserve some local (temp)
local2  var     256             ..memory on S stack
static  rmb     256             reserve some static memory
         begin                   procedure entry
         clr     local,s         access local mem
         clr     local2,s                access local mem
         lda     data,u          access a parameter
         sta     [address,u]     access a parameter
         clr     static          access static mem
         endproc

start   call    Asub,1024,65    call procedure
         rts

         end     start



-- 
Roger Taylor




More information about the Coco mailing list