home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / section5 / fxn09h.asm < prev    next >
Encoding:
Assembly Source File  |  1988-08-11  |  1.8 KB  |  33 lines

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;                 Function 09H: Display String               ;
  4.         ;                                                            ;
  5.         ;                 int disp_str(pstr)                         ;
  6.         ;                     char *pstr;                            ;
  7.         ;                                                            ;
  8.         ;                 Returns 0.                                 ;
  9.         ;                                                            ;
  10.         ;************************************************************;
  11.  
  12. cProc   disp_str,PUBLIC,<ds,di>
  13. parmDP  pstr
  14. cBegin
  15.         loadDP  ds,dx,pstr      ; DS:DX = pointer to string.
  16.         mov     ax,0900h        ; Prepare to write dollar-terminated
  17.                                 ; string to standard output, but
  18.                                 ; first replace the 0 at the end of
  19.                                 ; the string with '$'.
  20.         push    ds              ; Set ES equal to DS.
  21.         pop     es              ; (MS-C does not require ES to be
  22.                                 ; saved.)
  23.         mov     di,dx           ; ES:DI points at string.
  24.         mov     cx,0ffffh       ; Allow string to be 64KB long.
  25.         repne   scasb           ; Look for 0 at end of string.
  26.         dec     di              ; Scasb search always goes 1 byte too
  27.                                 ; far.
  28.         mov     byte ptr [di],'$' ; Replace 0 with dollar sign.
  29.         int     21h             ; Have MS-DOS print string.
  30.         mov     [di],al         ; Restore 0 terminator.
  31.         xor     ax,ax           ; Return 0.
  32. cEnd
  33.