home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / StandardGetFolder / StandardGetFolder source / PStrings.h next >
Encoding:
C/C++ Source or Header  |  1993-07-01  |  1.5 KB  |  42 lines  |  [TEXT/KAHL]

  1. /* PStrings.h -- A collection of useful pascal string functions. Chris Larson 1993    */
  2. /*               PStringCopy is based on (read: shamelessly stolen from) a remarkably */
  3. /*               similar routine placed into the public domain by Christopher Tate.   */
  4.  
  5. #ifndef __PSTRINGS__
  6. #define __PSTRINGS__
  7.  
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11.  
  12. #pragma parameter PStringCopy(__A0,__A1)
  13. void PStringCopy (StringPtr destination, StringPtr source) =
  14. {
  15.     0x7000,         //          moveq   #0, d0      ; clear d0
  16.     0x1011,         //          move.b  (a1), d0    ; init to string length
  17.     0x10D9,         // @x        move.b  (a1)+,(a0)+    ; move a byte
  18.     0x51C8, 0xFFFC  //          dbra    d0, @x          ; decrement and loop
  19. };
  20.  
  21. #pragma parameter PStringCat(__A0,__A1)
  22. void PStringCat (StringPtr string, StringPtr tail) =
  23. {
  24.     0x7000,         //      moveq   #0, d0          ; Clear d0
  25.     0x1010,         //      move.b  (a0), d0        ; string size into d0
  26.     0x7200,         //      moveq   #0, d1          ; clear d1
  27.     0x1219,         //      move.b  (a1)+, d1       ; tail length into d1
  28.     0x670C,            //        beq @done                ; exit if no tail
  29.     0xD318,         //      add.b   d1,(a0)+        ; total length to string
  30.     0xD0C0,         //      adda.w  d0, a0          ; offset a0 to string end
  31.     0x5341,            //        subq    #1,d1            ; correct # of loops
  32.     0x10D9,         //  @x  move.b  (a1)+, (a0)+    ; move a byte
  33.     0x51C9, 0xFFFC  //      dbra    d1, @x          ; decrement and loop
  34.                     //  @done
  35. };
  36.  
  37. #ifdef __cplusplus
  38. }
  39. #endif
  40.  
  41. #endif
  42.