[Coco] CCASM procedures

Roger Taylor rtaylor at bayou.com
Fri Dec 10 22:02:41 EST 2004


At 06:44 PM 12/10/2004, you wrote:
>Good.  If you have to pass as an argument, every global that a proc
>references, the args list gets pretty long, and the code is slower.

I tested a pass-by-ref demo which simple passed in the value of a symbol, 
then within the procedure I did a sta [param,u] which altered the outside 
object.  Simple enough.  But, addresses are 16-bit words, so passing a 
handful of addresses can be costly.

Another trick to avoid passing so many parameters on the stack is to pass a 
structure as pass-by-reference.  Send the base address in and let the 
procedure alter the fields of the structure.  You gotta love 
indirect+indexed addressing!

Btw, CCASM supports inheritance of structures.  You can even add more 
fields to the new structure.  Yepper... a tad towards the OOP paradigm, 
perhaps, but there's lot of other uses.

Here's what I would like to do, but some sort of scope control, display, or 
global symbol access will be needed.  Right now, procedures pretty much get 
their own namespace, but that was a quick workaround.  Instead of just the 
base data types (byte, word, dword, etc.) I want to be able to allow a 
structure to be a type you can set for a parameter you pass in.


color   struct
red     rmb     1
green   rmb     1
blue    rmb     1
         endstruct

color1  struct  color
         endstruct
color2  struct  color
         endstruct

clrcol  proc    _color:color
         begin   clrcol
         lda     #255
         sta     [_color.red,u]
         sta     [_color.green,u]
         sta     [_color.blue,u]
         endproc

start   call    clrcol,color1
         call    clrcol,color2
         rts

         end     start



-- 
Roger Taylor




More information about the Coco mailing list