home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / visionix / vinlineu.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-12-28  |  4.0 KB  |  219 lines

  1. {
  2.  ════════════════════════════════════════════════════════════════════════════
  3.  
  4.  Visionix Inline Unit (VSER)
  5.    Version 0.5
  6.  Copyright 1991,92,93 Visionix
  7.  ALL RIGHTS RESERVED
  8.  
  9.  ────────────────────────────────────────────────────────────────────────────
  10.  
  11.  revision history in reverse chronological order:
  12.  
  13.  Initials  Date      Comment
  14.  
  15.  ────────  ────────  ────────────────────────────────────────────────────────
  16.  
  17.  12/07/93  jrt       Started this unit.
  18.  
  19.  ────────────────────────────────────────────────────────────────────────────
  20. }
  21.  
  22. (*-
  23.  
  24. [SECTION: Section 1: The General Libraries]
  25. [CHAPTER: Chapter 8: The inline Function Library]
  26.  
  27. [TEXT]
  28.  
  29. <Overview>
  30.  
  31. This unit consists of functions which are (or will be) implemented as
  32. Borland Pascal 7.0 INLINE function types.
  33.  
  34. Currently this unit includes functions that replace the Turbo Pascal
  35. compilers string concatanation functions and expressions.  The TP
  36. functions and expressions (IE: the Concat function and the S := S+ '???'
  37. type expression) are _extremely_ slow.  As an example, by changing
  38. to these functions from the Concat function, the ANSI filter found
  39. in VANSIIOU increased in performance by over 40% on a 486/50 machine.
  40.  
  41. These functions are all implemented as fast assembly routines that
  42. do no paramater checking whatsoever.  When concatenating two string
  43. with these functions, the caller must make sure that the two
  44. strings will not be over 255 bytes in length when concatenated.
  45.  
  46. <Interface>
  47.  
  48. -*)
  49.  
  50.  
  51. Unit VInlineu;
  52.  
  53. Interface
  54.  
  55. Uses
  56.  
  57.   VTypesu;
  58.  
  59. Procedure StrAddCh(           Var S1             : STRING;
  60.                                   TheCH          : CHAR         );
  61.  
  62. Procedure StrAddStr(          Var S1             : STRING;
  63.                               Var S2             : STRING       );
  64.  
  65. Procedure StrAddConstStr(     Var S1             : STRING;
  66.                                   S2             : STRING       );
  67.  
  68.  
  69.  
  70.  
  71. Implementation
  72.  
  73. Procedure StrAddCh(           Var S1             : STRING;
  74.                                   TheCH          : CHAR         );
  75.  
  76. BEGIN
  77.  
  78.   ASM
  79.  
  80.     { get ptr to S1 in ES:DI }
  81.  
  82.     LES BX, [S1]
  83.  
  84.     { load AL with length of S1 }
  85.  
  86.     MOV AL, byte PTR ES:[BX]
  87.     XOR AH, AH
  88.  
  89.     { increment string length }
  90.  
  91.     INC byte PTR ES:[BX]
  92.  
  93.     { move string pointer down to proper spot }
  94.  
  95.     INC BL
  96.     ADD BX, AX
  97.  
  98.     MOV AL, TheCH
  99.     MOV byte PTR ES:[BX], AL
  100.  
  101.   END;
  102.  
  103. END;
  104.  
  105.  
  106. Procedure StrAddStr(          Var S1             : STRING;
  107.                               Var S2             : STRING       );
  108.  
  109. BEGIN
  110.  
  111.   ASM
  112.  
  113.     PUSH DS
  114.  
  115.     { get ptrs to strings }
  116.  
  117.     LES DI, [S1]
  118.     LDS SI, [S2]
  119.  
  120.     { get lengths (BX=len of s1, CX=len of s2) }
  121.  
  122.     MOV BL, byte PTR ES:[DI]
  123.     XOR BH, BH
  124.     MOV CL, byte PTR DS:[SI]
  125.     XOR CH, CH
  126.  
  127.     { move ptr to s2 down 1 byte (past length) }
  128.  
  129.     INC SI
  130.  
  131.     { add len of s1+len of s2; store as new length in s1 }
  132.  
  133.     MOV AL, BL
  134.     ADD AL, CL
  135.  
  136.     MOV byte PTR ES:[DI], AL
  137.  
  138.     { move ptr to s1 down to the end }
  139.  
  140.     INC DI
  141.     ADD DI, BX
  142.  
  143.     { append the string }
  144.  
  145.     CLD
  146.     REPZ MOVSB
  147.  
  148.     { restore DS }
  149.  
  150.     POP DS
  151.  
  152.   END;
  153.  
  154. END;
  155.  
  156. Procedure StrAddConstStr(     Var S1             : STRING;
  157.                                   S2             : STRING       );
  158.  
  159. BEGIN
  160.  
  161.   ASM
  162.  
  163.     PUSH DS
  164.  
  165.     { get ptrs to strings }
  166.     LES DI, [S1]
  167.  
  168.     LDS SI, dword PTR [S2]
  169.  
  170.     PUSH SS
  171.     POP  DS
  172.     LEA  SI, S2
  173.  
  174. {
  175.     PUSH SS
  176.     POP  DS
  177.     MOV  SI, offset S2
  178. }
  179.     { get lengths (BX=len of s1, CX=len of s2) }
  180.  
  181.     MOV BL, byte PTR ES:[DI]
  182.     XOR BH, BH
  183.     MOV CL, byte PTR DS:[SI]
  184.     XOR CH, CH
  185.  
  186.     { move ptr to s2 down 1 byte (past length) }
  187.  
  188.     INC SI
  189.  
  190.     { add len of s1+len of s2; store as new length in s1 }
  191.  
  192.     MOV AL, BL
  193.     ADD AL, CL
  194.  
  195.     MOV byte PTR DS:[DI], AL
  196.  
  197.     { move ptr to s1 down to the end }
  198.  
  199.     INC DI
  200.     ADD DI, BX
  201.  
  202.     { append the string }
  203.  
  204.     CLD
  205.     REPZ MOVSB
  206.  
  207.     { restore DS }
  208.  
  209.     POP DS
  210.  
  211.   END;
  212.  
  213. END;
  214.  
  215.  
  216.  
  217. BEGIN
  218.  
  219. END.