home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 January / Chip_2001-01_cd1.bin / tema / mysql / mysql-3.23.28g-win-source.exe / strings / bfill.c < prev    next >
C/C++ Source or Header  |  2000-08-31  |  2KB  |  82 lines

  1. /*  File   : bfill.c
  2.     Author : Richard A. O'Keefe.
  3.          Michael Widenius;    ifdef MC68000
  4.     Updated: 23 April 1984
  5.     Defines: bfill()
  6.  
  7.     bfill(dst, len, fill) moves "len" fill characters to "dst".
  8.     Thus to set a buffer to 80 spaces, do bfill(buff, 80, ' ').
  9.  
  10.     Note: the "b" routines are there to exploit certain VAX order codes,
  11.     but the MOVC5 instruction will only move 65535 characters.     The asm
  12.     code is presented for your interest and amusement.
  13. */
  14.  
  15. #include <global.h>
  16. #include "m_string.h"
  17.  
  18. #if !defined(bfill) && !defined(HAVE_BFILL)
  19.  
  20. #if VaxAsm
  21.  
  22. void bfill(dst, len, fill)
  23. char *dst;
  24. uint len;
  25. int fill; /* actually char */
  26. {
  27.   asm("movc5 $0,*4(ap),12(ap),8(ap),*4(ap)");
  28. }
  29.  
  30. #elif defined(MC68000) && defined(DS90)
  31.  
  32. void bfill(dst, len,fill)            /* Optimized with long-fill */
  33. char *dst;
  34. uint len;
  35. pchar fill;
  36. {
  37. asm("        movl    8.(a7),d1    ");
  38. asm("        jeq    .L9        ");
  39. asm("        movl    4.(a7),a0    ");
  40. asm("        moveq    #0,d0        ");
  41. asm("        movb    15.(a7),d0    ");
  42. asm("        movl    d2,a1        ");
  43. asm("        movw    d0,d2        ");
  44. asm("        aslw    #8,d0        ");
  45. asm("        orw    d2,d0        ");
  46. asm("        movl    d0,d2        ");
  47. asm("        swap    d0        ");
  48. asm("        orl    d2,d0        ");
  49. asm("        movl    a0,d2        ");
  50. asm("        btst    #0,d2        ");
  51. asm("        jeq    .L1        ");
  52. asm("        movb    d0,(a0)+    ");
  53. asm("        subql    #1,d1        ");
  54. asm(".L1:    movl    d1,d2        ");
  55. asm("        lsrl    #2,d2        ");
  56. asm("        jcc    .L2        ");
  57. asm("        movw    d0,(a0)+    ");
  58. asm("        jra    .L2        ");
  59. asm(".L3:    movl    d0,(a0)+    ");
  60. asm(".L2:    dbra    d2,.L3        ");
  61. asm("        addqw    #1,d2        ");
  62. asm("        subql    #1,d2        ");
  63. asm("        jcc    .L3        ");
  64. asm("        andl    #1,d1        ");
  65. asm("        jeq    .L8        ");
  66. asm("        movb    d0,(a0)        ");
  67. asm(".L8:    movl    a1,d2        ");
  68. asm(".L9:    rts            ");
  69. }
  70. #else
  71.  
  72. void bfill(dst, len, fill)
  73. register byte *dst;
  74. register uint len;
  75. register pchar fill;
  76. {
  77.   while (len-- != 0) *dst++ = fill;
  78. }
  79.  
  80. #endif
  81. #endif
  82.