home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / TUR6_101.ZIP / V25.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-06-07  |  6.9 KB  |  116 lines

  1. ;--------------------------------------------------------------------
  2. ; Author       : Kevin Dahl                                         :
  3. ; Last Revised : June 7, 1986                                       :
  4. ;                                                                   :
  5. ; FILENAME - V25.ENH                                                :
  6. ;                                                                   :
  7. ; WRITESTLN                                                         :
  8. ;        This routine displays any string to the display screen     :
  9. ;        starting at the place where the cursor is positioned.      :
  10. ;        This routine will also position the cursor after the last  :
  11. ;        character that is displayed to the screen.                 :
  12. ; ENTRY                                                             :
  13. ;        [bp+6]   = Length of string                                :
  14. ;        [bp+7]   = Ch[1] of string to be displayed on the screen.  :
  15. ;                                                                   :
  16. ; EXIT                                                              :
  17. ;        Nothing is returned                                        :
  18. ;--------------------------------------------------------------------
  19. writestln     proc      near
  20.               push      ds
  21.               push      bp                       ; save stack
  22.               mov       bp,sp
  23.               mov       ah,0fh                   ; get current video mode
  24.               int       10h                      ; using BIOS services
  25.               xor       dx,dx
  26.               mov       dl,ah                    ; save number columns per line
  27.               cmp       al,7                     ; check for monochrome monitor
  28.               je        v99
  29.               cmp       al,4                     ; check if text modes
  30.               jb        v97
  31.               jmp       v103                     ; graphics mode - no write
  32. v97:
  33.               mov       cx,7                     ; set for 40 col text modes
  34.               cmp       dl,80                    ; check for num of cols
  35.               jb        v98                      ; 40 cols if jmp
  36.               inc       cx                       ; if get here then 80 cols
  37. v98:
  38.               xor       ax,ax                    ; zero out ax
  39.               mov       al,bh                    ; active display page for CGA
  40.               push      bx                       ; save page #
  41.               shl       ax,cl                    ; calc address for display page
  42.               mov       cx,0B800h                ; address for CGA
  43.               add       ax,cx                    ; calc address to display string
  44.               jmp       v100
  45. v99:
  46.               mov       ax,0B000h                ; monochrome monitor address
  47. v100:
  48.               mov       es,ax                    ; video address into es
  49.  
  50.               push      dx                       ; save #cols/line
  51.               mov       ah,3                     ; get cursor location info
  52.               int       10h                      ; use BIOS services
  53.               xor       ax,ax                    ; zero out ax register
  54.               xor       bx,bx                    ; zero out bx register
  55.               mov       al,dh                    ; row coordinate
  56.               mov       bl,dl                    ; col coordinate
  57.  
  58.               pop       dx                       ; get #cols/line
  59.               mul       dx                       ; row * number of columns
  60.               add       ax,bx                    ; row * # cols + col offset
  61.               shl       ax,1                     ; row * #cols + col offset * 2
  62.               mov       di,ax                    ; offset in display scrn for string
  63.  
  64.               mov       cx,[bp+6]                ; length of string
  65.               xor       ch,ch                    ; remove first character from ch
  66.               cmp       cx,1
  67.               jb        v103                     ; no string to display
  68.               mov       ax,bp                    ; address of base page into ax
  69.               add       ax,7                     ; calc offset of string in stack
  70.               mov       si,ax                    ; move offset of string into si
  71.               mov       ax,ss
  72.               mov       ds,ax                    ; stack segment into data segment
  73.               mov       bl,[bp+262]              ; attribute byte into bl
  74.               mov       dx,03DAh                 ; status port
  75.               cld                                ; clear direction flag
  76.               cli                                ; clear interrupts
  77. v101:
  78.               in        al,dx                    ; get status
  79.               rcr       al,1                     ; is it low?
  80.               jb        v101                     ; wait until it is
  81. v102:
  82.               in        al,dx                    ; get status
  83.               rcr       al,1                     ; is it high?
  84.               jnb       v102                     ; wait until it is
  85.  
  86.               movsb                              ; display character
  87.               inc       di                       ; skip attribute byte
  88.               loop      v101                     ; repeat until all characters displayed
  89.               sti                                ; turn interrupts back on
  90.  
  91.               mov       ah,15                    ; get video mode information
  92.               int       10h                      ; using BIOS services
  93.               mov       bl,ah                    ; move #cols/line
  94.               push      bx                       ; save cols/line & page#
  95.               mov       ah,3                     ; get the current x,y coordinates
  96.               int       10h                      ; of the cursor using BIOS serives
  97.               xor       ax,ax                    ; zero out the ax register
  98.               mov       al,dl                    ; col# into al
  99.               add       al,[bp+6]                ; add string length
  100.               pop       bx                       ; get # cols/line
  101.               push      dx                       ; save row, col information
  102.               div       bl                       ; length(st) div #cols/line
  103.               pop       dx                       ; get row, col information
  104.               add       dh,al                    ; calc new row position
  105.               inc       dh
  106.               xor       dl,dl                    ; new col position
  107.               mov       ah,2                     ; use BIOS services to set
  108.               int       10h                      ; new cursor position
  109. v103:
  110.               mov       sp,bp                    ; restore stack
  111.               pop       bp                       ; restore base pointer
  112.               pop       ds                       ; restore data segment
  113.               ret       256                      ; remove parameters and return
  114. writestln     endp
  115.  
  116.