home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / PowerPC / Dev / PPCRelease / Examples / AmigaOS / callm68ksync.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-07  |  1.5 KB  |  68 lines

  1. #include <exec/types.h>
  2. #include <exec/nodes.h>
  3. #include <exec/lists.h>
  4. #include <exec/memory.h>
  5. #include <powerup/ppclib/interface.h>
  6. #include <powerup/gcclib/powerup_protos.h>
  7.  
  8.  
  9. /* This is in no way a useful 68k function
  10.  * or a style of programming i suggest:-)
  11.  */
  12.  
  13. UWORD    M68kProgram[]=
  14. {
  15. /*
  16. Color:
  17. ;d0=color
  18.     move.l    d2,-(a7)
  19.     moveq    #-1,d1
  20.     moveq    #20,d2
  21. 0$:
  22.     move.w    d0,$dff180
  23.     dbra    d1,0$
  24.     dbra    d2,0$
  25.     move.l    (a7)+,d2
  26.     rts
  27. */
  28.  
  29.   0x2f02,
  30.   0x72ff,
  31.   0x7414,
  32.   0x33c0,
  33.   0x00df,
  34.   0xf180,
  35.   0x51c9,
  36.   0xfff8,
  37.   0x51ca,
  38.   0xfff4,
  39.   0x241f,
  40.   0x4e75
  41. };
  42.  
  43. int    main(void)
  44. {
  45. struct Caos    *MyCaos;
  46.  
  47.   if (MyCaos = (struct Caos*) PPCAllocVec(sizeof(struct Caos),
  48.                                           MEMF_PUBLIC|MEMF_CLEAR))
  49.   {
  50.     MyCaos->caos_Un.Function    =    (APTR) &M68kProgram;
  51.     /* Look at the M68k function above and you see that this
  52.        function doesn`t touch any memory the PPC uses or
  53.        will use after the function returns.
  54.        BUT let`s assume you would call AllocMem now and pass back
  55.        that ptr to the PPC program you would need to set CacheFlush
  56.        TRUE. Attention..you`re aren`t allowed to use normal AllocMem
  57.        areas anyway because of the needed CacheLine Alignment only
  58.        the ppc.library functions offer.
  59.      */
  60.     MyCaos->M68kCacheMode    =    IF_CACHEFLUSHNO;
  61.     MyCaos->PPCCacheMode    =    IF_CACHEFLUSHNO;
  62.     MyCaos->d0            =    0x0ff;            /* the value the 68k function writes into color reg 0 */
  63.     PPCCallM68k(MyCaos);
  64.     PPCFreeVec(MyCaos);
  65.   }
  66.   return(0);
  67. }
  68.