home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / basic / mxshka.asm < prev    next >
Encoding:
Assembly Source File  |  1989-11-09  |  2.2 KB  |  54 lines

  1. ;*************************** SHAKESPEARE ******************************
  2. ; This program creates two strings and passes them to a BASIC procedure
  3. ; called addstring (in file MXADSTB.BAS).  This procedure concatenates
  4. ; the strings and passes the result to MASM which prints it.
  5.  
  6.         .model  medium,basic        ;Use same memory model as BASIC.
  7.         .stack
  8.         .data                       ;Create the data.
  9. phrase1         db      "To be or not to be;"
  10. phrase1len      dw      $-phrase1
  11. phrase1off      dw      phrase1
  12. phrase2         db      " that is the question."
  13. phrase2len      dw      $-phrase2
  14. phrase2off      dw      phrase2
  15. sentence        db      100 dup(0)  ;Make room for return data
  16. sentencelen     dw      0           ;and a length indicator.
  17. sentenceoff     dw      sentence
  18.  
  19.         .code
  20. shakespeare proc    uses si
  21.  
  22. ;First call BASIC to concatenate strings.
  23.         lea     ax,phrase1off       ;Push far address of
  24.         push    ax                  ;fixed-length string #1,
  25.         lea     ax,phrase1len       ;and its length.
  26.         push    ax
  27.         lea     ax,phrase2off       ;Do the same for the
  28.         push    ax                  ;address of string #2,
  29.         lea     ax,phrase2len       ;and its length.
  30.         push    ax
  31.         lea     ax,sentenceoff      ;Push far address of
  32.         push    ax                  ;the return string,
  33.         lea     ax,sentencelen      ;and its length.
  34.         push    ax
  35.         extrn   addstring:proc      ;Call BASIC function to
  36.         call    addstring           ;concatenate the strings and
  37.                                     ;put the result in the
  38.                                     ;fixed-length return string.
  39.  
  40. ;Call DOS to print string. The DOS string output routine (09H)
  41. ;requires that strings end with a "$" character.
  42.         mov     bx,sentencelen      ;Go to end of the result string
  43.         lea     si,sentence         ;and add a "$" (24h) character.
  44.         mov     byte ptr [bx + si],24h
  45.  
  46.         lea     dx,sentence         ;Set up registers
  47.         mov     ah,9                ;and call DOS to
  48.         int     21h                 ;print result string.
  49.         ret
  50.  
  51. shakespeare endp
  52.  
  53.         end
  54.