home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Editors / emacs / Emacs-1.14b1-sources / sources / misc-src / bfuncs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-17  |  1.3 KB  |  95 lines  |  [TEXT/EMAC]

  1. /*
  2.  * Copyright (C) 1993, 1994 Marc Parmet.
  3.  * This file is part of the Macintosh port of GNU Emacs.
  4.  *
  5.  * GNU Emacs is distributed in the hope that it will be useful,
  6.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  8.  * GNU General Public License for more details.
  9.  */
  10.  
  11. #if defined(THINK_C)
  12.  
  13. void
  14. bzero(char *b,int n)
  15. {
  16.     asm {
  17.             move.l    b,a0
  18.             move.l    n,d0
  19.             bra.s    @test
  20.         
  21.     top1:    swap.w    d0
  22.     top2:    clr.b    (a0)+
  23.     test:    dbf.w    d0,@top2
  24.             swap.w    d0
  25.             dbf.w    d0,@top1
  26.     }
  27. }
  28.  
  29. void
  30. bcopy(char *b1,char *b2,int n)
  31. {
  32.     asm {
  33.             move.l    b1,a0
  34.             move.l    b2,a1
  35.             move.l    n,d0
  36.             bra.s    @test
  37.         
  38.     top1:    swap.w    d0
  39.     top2:    move.b    (a0)+,(a1)+
  40.     test:    dbf.w    d0,@top2
  41.             swap.w    d0
  42.             dbf.w    d0,@top1
  43.     }
  44. }
  45.  
  46. int
  47. bcmp(char *b1,char *b2,int n)
  48. {
  49.     asm {
  50.             move.l    b1,a0
  51.             move.l    b2,a1
  52.             move.l    n,d0
  53.             move.w    #4,ccr ; set Z bit
  54.             bra.s    @test
  55.         
  56.     top1:    swap.w    d0
  57.     top2:    cmpm.b    (a0)+,(a1)+
  58.     test:    dbne.w    d0,@top2
  59.             bne.s    @nomatch
  60.             swap.w    d0
  61.             dbf.w    d0,@top1
  62.             moveq.l    #0,d0
  63.             return
  64.     nomatch:moveq.l    #1,d0
  65.     }
  66. }
  67.  
  68. #else
  69.  
  70. void
  71. bzero(char *b,int n)
  72. {
  73.     while (n--)
  74.         *b++ = 0;
  75. }
  76.  
  77. void
  78. bcopy(char *b1,char *b2,int n)
  79. {
  80.     while (n--)
  81.         *b2++ = *b1++;
  82. }
  83.  
  84. int
  85. bcmp(char *b1,char *b2,int n)
  86. {
  87.     while (n--)
  88.         if (*b1++ != *b2++)
  89.             return 1;
  90.     
  91.     return 0;
  92. }
  93.  
  94. #endif
  95.