home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l196 / 3.ddi / MXADSTA.AS$ / MXADSTA.bin
Encoding:
Text File  |  1990-06-24  |  3.4 KB  |  75 lines

  1. ;***************************** ADDSTRING ********************************
  2. ; This procedure accepts two far strings, concatenates them, and
  3. ; returns the result in the form of a far string.
  4.  
  5.         .model  medium,basic        ;Define memory model to match BASIC.
  6.     extrn    STRINGASSIGN:far
  7.     .stack
  8.         .data?
  9.         maxst = 50                  ;Maximum bytes reserved for strings
  10. inbuffer1       db  maxst dup(0)    ;Room for first fixed-length string
  11. inbuffer2       db  maxst dup(0)    ;and second one
  12. outbuffer       db  2*maxst dup(0)  ;Work area for string processing
  13.         .data
  14. sh              dd  0               ;Output string descriptor
  15.         .code
  16. ADDSTRING    proc    uses si di ds, s1:far ptr, s1len, s2:far ptr, s2len
  17.  
  18. ;First get BASIC to convert BASIC strings into standard form.
  19.         les     ax,s1               ;Push far pointer to
  20.         push    es                  ;input string descriptor.
  21.         push    ax
  22.         xor     ax,ax               ;Push a zero to indicate
  23.         push    ax                  ;it is variable length.
  24.         push    ds                  ;Push far pointer to
  25.         lea     ax, inbuffer1       ;destination string.
  26.         push    ax
  27.         mov     ax,maxst            ;Push length of destination
  28.         push    ax                  ;fixed-length string.
  29.     call    STRINGASSIGN        ;Call BASIC to assign variable-length
  30.                                     ;string to fixed-length string.
  31.         les     ax,s2               ;Push far pointer to second
  32.         push    es                  ;input string descriptor.
  33.         push    ax
  34.         xor     ax,ax               ;Push a zero to indicate
  35.         push    ax                  ;it is variable length.
  36.         push    ds                  ;Push far pointer to
  37.         lea     ax,inbuffer2        ;second destination string.
  38.         push    ax
  39.         mov     ax,maxst            ;Push length of destination
  40.         push    ax                  ;fixed-length string.
  41.     call    STRINGASSIGN        ;Call BASIC to assign variable-length
  42.                                     ;string to fixed-length string.
  43. ;Concatenate strings.
  44.         lea     si,inbuffer1        ;Copy first string to buffer.
  45.         lea     di,outbuffer
  46.         mov     ax,ds
  47.         mov     es,ax
  48.         mov     cx,s1len
  49.         rep     movsb
  50.         lea     si,inbuffer2        ;Concatenate second string to
  51.         mov     cx,s2len            ;end of first.
  52.         rep     movsb
  53.  
  54. ;Get BASIC to convert result back into a BASIC string.
  55.         push    ds                  ;Push far pointer to fixed-length
  56.         lea     ax,outbuffer        ;result string.
  57.         push    ax
  58.         mov     ax,s1len            ;Compute total length of
  59.         mov     bx,s2len            ;fixed-length result string.
  60.         add     ax,bx
  61.         push    ax                  ;Push length.
  62.         push    ds                  ;Push far pointer to sh (BASIC
  63.         lea     ax,sh               ;will use this in StringAssign).
  64.         push    ax
  65.         xor     ax,ax               ;Push a zero for length
  66.         push    ax                  ;indicating variable-length.
  67.     call    STRINGASSIGN    ;Call BASIC to assign the
  68.                                     ;result to sh.
  69.         lea     ax,sh               ;Return output string pointer
  70.                                     ;in ax and go back to BASIC.
  71.         ret
  72.  
  73. ADDSTRING    endp
  74.                 end
  75.