home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / DSMODS / ASM.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  3.1 KB  |  188 lines

  1. #include    "defs.h"
  2.  
  3. /*
  4.     This module is a good candidate to be rewritten
  5.     in assembly language.
  6. */
  7. /*
  8.     Following Block move routines support a long data count.
  9.     The 64K ones are written in assembly code in file "stuffptr.s".
  10. */
  11. /*
  12.     Function to forward move a block.
  13. */
  14. /*
  15. Lf_move(source, target, count)
  16. unsigned char    *source, *target;
  17. unsigned long    count;
  18. {
  19.     while (count--) *target++ = *source++;
  20. }
  21. */
  22. /*
  23.     Function to reverse move a block.
  24. */
  25. Lr_move(source, target, count)
  26. unsigned char    *source, *target;
  27. unsigned long    count;
  28. {
  29.     while (count--) *target-- = *source--;
  30. }
  31.  
  32. /*
  33.     Function to copy a block.
  34. */
  35. memcpy(target, source, count)
  36. unsigned char    *target, *source;
  37. unsigned    count;
  38. {
  39.     f_move(source, target, count);
  40. }
  41.  
  42. /*
  43.     Function to fill a block with a byte value.
  44. */
  45. memset(target, value, count)
  46. unsigned char    *target, value;
  47. unsigned    count;
  48. {
  49.     while (count--) *target++ = value;
  50. }
  51.  
  52. /*
  53.     Function to compare two blocks.
  54. */
  55. memcmp(target, source, count)
  56. unsigned char    *target, *source;
  57. unsigned    count;
  58. {
  59.     while (count--) if (*target++ != *source++)
  60.         return(1);
  61.     return(0);
  62. }
  63.  
  64. /*
  65.     Routine to truncate source string "s" at '.' by looking backward.
  66.     Process is stopped if a '\' is found.
  67. */
  68. strunc(s)
  69. unsigned char    s[];
  70. {
  71.     unsigned    i;
  72.     unsigned char    c;
  73.  
  74.     i = strlen(s);
  75.     while (i && (c = s[i-1]) != '\\' && c != '.')
  76.         --i;
  77.     if (c == '.') s[i-1] = 0;
  78. }
  79.  
  80. /*
  81.     Function to change a lower case alpha character to upper case.
  82.     Returns new or old character.
  83. */
  84. char    toupper(c)
  85. char    c;
  86. {
  87.     if (c >= 'a' && c <= 'z') c -= 0x20;
  88.     return(c);
  89. }
  90.  
  91. /*
  92.     Routine to check if character "c" is an alphabet.
  93.     True returns 1 else 0.
  94. */
  95. calpha(c)
  96. char    c;
  97. {
  98.     return((c >= 'A' && c <= 'Z')||(c >= 'a' && c <= 'z'));
  99. }
  100.  
  101. /*
  102.     Routine to check if character "c" is a digit.
  103.     True returns 1 else 0.
  104. */
  105. cdigit(c)
  106. char    c;
  107. {
  108.     return(c >= '0' && c <= '9');
  109. }
  110.  
  111. /*
  112.     Routine to check if character "c" is a Start or End CP TAG.
  113.     True returns 1 else 0.
  114. */
  115. ctagc(c)
  116. char    c;
  117. {
  118.     return(c == STAG || c == ETAG);
  119. }
  120.  
  121. /*
  122.     Routine to check if character "c" is a PI TAG.
  123.     True returns 1 else 0.
  124. */
  125. ptagc(c)
  126. char    c;
  127. {
  128.     return(c == PTAG);
  129. }
  130.  
  131. /*
  132.     Routine to check if character "c" is a PI or CP TAG.
  133.     True returns 1 else 0.
  134. */
  135. tagc(c)
  136. char    c;
  137. {
  138.     return(ptagc(c) || ctagc(c));
  139. }
  140.  
  141. /*
  142.     Function to check if char c is a non compose one.
  143.     True returns 1 else 0.
  144. */
  145. nocp(c)
  146. char    c;
  147. {
  148.     return( c == DH || c == cr || c == lf || c == Rf ||
  149.         c == QL || c == QR || c == QC );
  150. }
  151.  
  152. /*
  153.     Function to check if char c is any line ending one.
  154.     True returns 1 else 0.
  155. */
  156. allend(c)
  157. char    c;
  158. {
  159.     return(c == srt || c == hrt || c == Rf);
  160. }
  161.  
  162. /*
  163.     Function to check if char at "ptr" is any cursor line ending one.
  164.     True returns 1 else 0.
  165. */
  166. lpend(ptr)
  167. char    *ptr;
  168. {
  169.     return(*ptr == cr || allend(*ptr));
  170. }
  171.  
  172. /*
  173.     Function to setup Long char format.
  174. */
  175. start(arr,i,c)
  176. unsigned char    *arr;
  177. unsigned    i;
  178. unsigned char    c;
  179. {
  180.     union {
  181.         unsigned char    byt[2];
  182.         unsigned    val;
  183.     } w;
  184.     w.val    = i | (c << 8);
  185.     *(++arr)= w.byt[0];
  186.     *(++arr)= w.byt[1];
  187. }
  188.