home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT8 / PUTSTR.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  3.0 KB  |  74 lines

  1. ;-----------------------------------------------------------
  2. ;
  3. ;  Program PutStr ( Chapter 8 )
  4. ;
  5. ;  Procedure for an ASCIIZ-string onto the screen
  6. ;
  7. ;  Author:  A.I.Sopin      VSU,     Voronezh, 1992
  8. ;
  9. ;  Input parameters:
  10. ;
  11. ;  DS:SI -address of the start of a text string
  12. ;
  13. ;  CX - counter of characters been written (<= 80)
  14. ;
  15. ;  Otherwise the string length is assumed when the zero byte is reached
  16. ;
  17. ;  AH - attribute of a character being written
  18. ;
  19. ;  DX - address for outputting a string
  20. ;
  21. ;  DH - starting line  (0 --- 24)
  22. ;
  23. ;  DL - starting column (0 --- 79)
  24. ;
  25. ;  External procedures being used: 
  26. ;
  27. ;  VIDTYP - determining of video adapter type and segment address
  28. ;
  29. ;  WRCHAR - writing of character + attribute into video buffer
  30. ;-----------------------------------------------------------
  31.  
  32. EXTRN   VIDTYP : FAR, WRCHAR : FAR
  33.  
  34. .MODEL  SMALL
  35. .CODE
  36. PUTSTR  PROC    FAR
  37.         PUBLIC  PUTSTR
  38.         push    bx                      ;  save video page number
  39.         push    cx                      ;  save length counter
  40.         push    dx                      ;  save output address
  41.         push    si                      ;  save output address
  42.         push    bp                      ;  save output address
  43.         push    es                      ;  save output address
  44. ;  Determining the video adapter type and thesegment address
  45.         push    ax                      ;
  46.         push    cx                      ;  save counter-delimiter
  47.         push    dx                      ;  save line-column
  48.         Call    VIDTYP                  ;  determining video adapter type
  49.         mov     bl,al                   ;  video adapter type
  50.         mov     es,dx                   ;  video buffer address
  51.         pop     dx                      ;  restore line-column
  52.         pop     cx                      ;  restore delimiter
  53.         pop     ax                      ;
  54. ;  Cycle on reading one character of the string and writing to video buffer
  55. Cycle:  lodsb                           ;  pass a character 
  56.         and     al,al                   ;  is the end of the string reached ?
  57.         jz      Exit                    ;  don't output 0 !!!
  58.         mov     bp,cx                   ;  save counter
  59.         mov     cx,1                    ;  output one character
  60.         Call    WRCHAR                  ;  write character at the address: DH, DL
  61.         mov     cx,bp                   ;  restore counter
  62.         inc     dl                      ;  modify column of output
  63.         loop    Cycle                   ;  to the start of the cycle
  64. ;  Restoring the registers and exit
  65. Exit:   pop     es                      ;
  66.         pop     bp                      ;
  67.         pop     si                      ;
  68.         pop     dx                      ;  restore address for output
  69.         pop     cx                      ;  restore length counter
  70.         pop     bx                      ;  restore address of line
  71.         RETF
  72. PUTSTR  ENDP
  73.         END
  74.