home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s1.arc / DUPL.MOD < prev    next >
Text File  |  1987-11-10  |  4KB  |  56 lines

  1. (*--------------------------------------------------------------------------*)
  2. (*                     Dupl -- Duplicate a character n times                *)
  3. (*--------------------------------------------------------------------------*)
  4.  
  5. FUNCTION Dupl( Dup_char : Char; Dup_Count: INTEGER ) : AnyStr;
  6.  
  7. (*--------------------------------------------------------------------------*)
  8. (*                                                                          *)
  9. (*    Function: Dupl                                                        *)
  10. (*                                                                          *)
  11. (*    Purpose:  Duplicate a character n times                               *)
  12. (*                                                                          *)
  13. (*    Calling Sequence:                                                     *)
  14. (*                                                                          *)
  15. (*       Dup_String := Dupl( Dup_Char: Char; Dup_Count: INTEGER ): AnyStr;  *)
  16. (*                                                                          *)
  17. (*          Dup_Char   --- Character to be duplicated                       *)
  18. (*          Dup_Count  --- Number of times to duplicate character           *)
  19. (*          Dup_String --- Resultant duplicated string                      *)
  20. (*                                                                          *)
  21. (*          Note:  If Dup_Count <= 0, a null string is returned.            *)
  22. (*                                                                          *)
  23. (*    Calls:  None                                                          *)
  24. (*                                                                          *)
  25. (*                                                                          *)
  26. (*    Remarks:                                                              *)
  27. (*                                                                          *)
  28. (*       This routine could be programmed directly in Turbo as:             *)
  29. (*                                                                          *)
  30. (*          VAR                                                             *)
  31. (*             S    : AnyStr;                                               *)
  32. (*                                                                          *)
  33. (*          BEGIN                                                           *)
  34. (*                                                                          *)
  35. (*             FillChar( S[1], Dup_Count, Dup_Char );                       *)
  36. (*             S[0] := CHR( Dup_Count );                                    *)
  37. (*                                                                          *)
  38. (*             Dupl := S;                                                   *)
  39. (*                                                                          *)
  40. (*          END;                                                            *)
  41. (*                                                                          *)
  42. (*--------------------------------------------------------------------------*)
  43.  
  44. BEGIN (* Dupl *)
  45.  
  46. INLINE(
  47.   $8B/$4E/$06/           {         MOV       CX,[BP+6]  ; Pick up dup count}
  48.   $C4/$7E/$0A/           {         LES       DI,[BP+10] ; Result address}
  49.   $FC/                   {         CLD                  ; Set direction flag}
  50.   $88/$C8/               {         MOV       AL,CL      ; Get result length}
  51.   $AA/                   {         STOSB                ; Store result length}
  52.   $8B/$46/$08/           {         MOV       AX,[BP+8]  ; Get char to duplicate}
  53.   $F2/$AA);              {         REP       STOSB      ; Perform duplication}
  54.  
  55. END   (* Dupl *);
  56.