•  Back 
  •  mec0 (MPS) interface 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help page 
  •  Show info about hypertext 
  •  View a new file 
Topic       : TOS - The Operating System
Author      : 
Version     : tos.hyp (December 19, 2008)
Subject     : Programmieren/Atari
Nodes       : 3010
Index Size  : 93790
HCP-Version : 5
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Title
@help       : 
@options    : +g -i -s +x +zz -t4
@width      : 70
View Ref-File12.2.1.5  mps_demo.cpp                                             TOS

// Tab size: 3

// Last change:  15.08.96
// Author:   FS

// ------------------------------------------------------------------------------
// Demo example for (!nolink [MagiC]) PC programmer's interface (MPS)
//
// Parl 2: User-defined functions, freely alterable
// =======
//
// ------------------------------------------------------------------------------

#include "windows.h"
#include "mps_base.h"
#include "mps_demo.h"

   MPS_magicinfo m_info;               // Global for the DLL

//
// List of the user-defined functions (alter/extend as required):
// ------------------------------------------------------------------
   static void demo_0(MPS_motregs *r);
   static void demo_1(MPS_motregs *r);
   static void demo_3(MPS_motregs *r);
   static void copy_string(MPS_motregs *r);

   MPS_fuptr my_funclist[] = {
     demo_0,                       // Demo function 0
     demo_1,                       // Demo function 1
     (MPS_fuptr) -1,               // -1 (i.e function No.2 not defined)
     demo_3,                       // Demo function 3
     copy_string,                  // Demo function 4
     NULL                          // !! A NULL-entry at list end !!
     } ;


// ******************************************************************
//
// Here the user-defined functions:
// ================================
//

// Demo_0 only returns the value 1 in d0:
//
   static void demo_0(MPS_motregs *r)
// ----------------------
 {
   r->d0 = 1;                       // Demo-0 sets d0 to 1
   return;
 }

// Demo_1 adds the registers d1 and d2; result to d0:
//
   static void demo_1(MPS_motregs *r)
// ----------------------
 {
   r->d0 = r->d1 + r->d2;
   return;
 }

// Demo_3 does nothing at all!
//
   static void demo_3(MPS_motregs *r)
// ----------------------
 {
   return;
 }

// Demo routine_4 copy_string copies a string to Motorola address space:
//                -----------
// a0: Destination address,
// d0: Maximum number of characters (incl. 0)
//
   static void copy_string(MPS_motregs *r)
// -----------------------
 {
   static char string[] = "This is a demo-text of copy_string(..)";

   int i, nchmax;
   char *dest;

   nchmax = (int) r->d0;
   dest = (char *) (*m_info.intel_ptr)(r->a0);
   if (nchmax<=0 || dest==NULL) return;         // Invalid?

   for (i=0; i<nchmax; i++) {
     if ((dest[i] = string[i])==0)
       return;
     }
   dest[nchmax-1] = 0;                          // Too long->truncate
   return;
 }

See also: MagiC PC interface