bfill.c
Upload User: tsgydb
Upload Date: 2007-04-14
Package Size: 10674k
Code Size: 2k
Category:

MySQL

Development Platform:

Visual C++

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