Re: [cc65] Inserting Assembly Routines

Date view Thread view Subject view

From: MagerValp (MagerValp_at_cling.gu.se)
Date: 2002-11-25 15:09:28


>>>>> "g" == groepaz  <groepaz_at_gmx.net> writes:

g> if you want to create a library in assembler, just take the cc65
g> runtime library as an example.... basically nothing more than
g> putting the asm code into seperate source files, assemble them to
g> an object file and making a library from them.

This is easier said than done though. It takes a while to figure out
argument passing, and there's no nice reference of what all the small
runtime routines are and what they do. My solution to this was:

void CopyFromSuperRAM(void *dest, unsigned char sourcebank, void
*source, unsigned int length) {
  *(unsigned char *)0x005f = dest;
  *(unsigned char *)0x0061 = sourcebank;
  *(unsigned char *)0x0062 = source;
  *(unsigned char *)0x0064 = length;

  __asm__ ("ldy #0");      /* just some dummy code */
  __asm__ ("lda ($62),y");
  __asm__ ("sta ($5f),y");
}

and assemble with cc65 -O -t c64 test.c. Then I cut and paste the
generated source to my library file and use that as the base for the
function. This way cc65 automatically inserts all the necessary jsr
popax and whatnot.

-- 
    ___          .     .  .         .       . +  .         .      o   
  _|___|_   +   .  +     .     +         .  Per Olofsson, arkadspelare
    o-o    .      .     .   o         +          MagerValp_at_cling.gu.se
     -       +            +    .     http://www.cling.gu.se/~cl3polof/
----------------------------------------------------------------------
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 : 2002-11-25 15:10:25 CET