home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Simulation / PDP-8 Simulator / Source Code / Assembler / Global.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-13  |  1.0 KB  |  54 lines  |  [TEXT/KAHL]

  1. /************************************************************
  2. *
  3. *
  4. *    Global functions for the PDP-8 assembler.
  5. *
  6. *    by Adrian Bool in cooperation with Graham Cox.
  7. *
  8. *    copyright © phantasm coding 1992.
  9. *
  10. *
  11. ************************************************************/
  12.  
  13. #include "Global.h"
  14.  
  15. #include "Global.proto.h"
  16.  
  17. void PascalToC(str255 cString , char *pString)
  18.     {
  19.     short stringLength;
  20.     short x;
  21.     
  22.     stringLength = (int) pString[0];
  23.     
  24.     if (stringLength > 255) stringLength = 255;
  25.     
  26.     for (x = 1 ; x <= stringLength ; x++) cString[x-1] = pString[x];
  27.     cString[x] = (char) 0;
  28.     }
  29.     
  30. void CtoPascal(str255 pString , char *cString)
  31.     {
  32.     short stringLength;
  33.     
  34.     stringLength = lengthOfString(cString);
  35.     if (stringLength > 255) stringLength = 255;
  36.     
  37.     copyString(pString+1,cString);
  38.     pString[0] = (char) stringLength;
  39.     }
  40.     
  41. void copyString(char *dest , char *source)
  42.     {
  43.     short x;
  44.     
  45.     for(x=0; (dest[x] = source[x]) != '\0' ; x++);
  46.     }
  47.     
  48. short lengthOfString(char *theString)
  49.     {
  50.     short x;
  51.     
  52.     for(x=0 ; theString[x] != '\0' ; x++);
  53.     return(x);
  54.     }