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

  1. ;--------------------------------------------------------------------
  2. ; Author       : Kevin Dahl                                         :
  3. ; Last Revised : June 7, 1986                                       :
  4. ;                                                                   :
  5. ; FILENAME - V24.ENH                                                :
  6. ;                                                                   :
  7. ; WRITEST                                                           :
  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. writest       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        v92
  29.               cmp       al,3                     ; check if text modes
  30.               ja        v96                      ; graphics mode - no write
  31.               mov       cx,7                     ; set for 40 col text modes
  32.               cmp       dl,80                    ; check for num of cols
  33.               jb        v91                      ; 40 cols if jmp
  34.               inc       cx                       ; if get here then 80 cols
  35. v91:
  36.               xor       ax,ax                    ; zero out ax
  37.               mov       al,bh                    ; active display page for CGA
  38.               push      bx                       ; save page #
  39.               shl       ax,cl                    ; calc address for display page
  40.               mov       cx,0B800h                ; address for CGA
  41.               add       ax,cx                    ; calc address to display string
  42.               jmp       v93
  43. v92:
  44.               mov       ax,0B000h                ; monochrome monitor address
  45. v93:
  46.               mov       es,ax                    ; video address into es
  47.  
  48.               push      dx                       ; save #cols/line
  49.               mov       ah,3                     ; get cursor location info
  50.               int       10h                      ; use BIOS services
  51.               xor       ax,ax                    ; zero out ax register
  52.               xor       bx,bx                    ; zero out bx register
  53.               mov       al,dh                    ; row coordinate
  54.               mov       bl,dl                    ; col coordinate
  55.  
  56.               pop       dx                       ; get #cols/line
  57.               mul       dx                       ; row * number of columns
  58.               add       ax,bx                    ; row * # cols + col offset
  59.               shl       ax,1                     ; row * #cols + col offset * 2
  60.               mov       di,ax                    ; offset in display scrn for string
  61.  
  62.               mov       cx,[bp+6]                ; length of string
  63.               xor       ch,ch                    ; remove first character from ch
  64.               cmp       cx,1
  65.               jb        v96                      ; no string to display
  66.               mov       ax,bp                    ; address of base page into ax
  67.               add       ax,7                     ; calc offset of string in stack
  68.               mov       si,ax                    ; move offset of string into si
  69.               mov       ax,ss
  70.               mov       ds,ax                    ; stack segment into data segment
  71.               mov       bl,[bp+262]              ; attribute byte into bl
  72.               mov       dx,03DAh                 ; status port
  73.               cld                                ; clear direction flag
  74.               cli                                ; clear interrupts
  75. v94:
  76.               in        al,dx                    ; get status
  77.               test      al,1                     ; is it low?
  78.               jnz       v94                      ; wait until it is
  79. v95:
  80.               in        al,dx                    ; get status
  81.               test      al,1                     ; is it high?
  82.               jz        v95                      ; wait until it is
  83.               movsb                              ; display character
  84.               inc       di                       ; skip attribute byte
  85.               loop      v94                      ; repeat until all characters displayed
  86.               sti                                ; turn interrupts back on
  87.  
  88.               mov       ah,15                    ; get video mode information
  89.               int       10h                      ; using BIOS services
  90.               mov       bl,ah                    ; move #cols/line
  91.               push      bx                       ; save cols/line & page#
  92.               mov       ah,3                     ; get the current x,y coordinates
  93.               int       10h                      ; of the cursor using BIOS serives
  94.               xor       ax,ax                    ; zero out the ax register
  95.               mov       al,dl                    ; col# into al
  96.               add       al,[bp+6]                ; add string length
  97.               pop       bx                       ; get # cols/line
  98.               push      dx                       ; save row, col information
  99.               div       bl                       ; length(st) div #cols/line
  100.               pop       dx                       ; get row, col information
  101.               add       dh,al                    ; calc new row position
  102.               mov       dl,ah                    ; new col position
  103.               mov       ah,2                     ; use BIOS services to set
  104.               int       10h                      ; new cursor position
  105. v96:
  106.               mov       sp,bp                    ; restore stack
  107.               pop       bp                       ; restore base pointer
  108.               pop       ds                       ; restore data segment
  109.               ret       256                      ; remove parameters and return
  110. writest       endp
  111.  
  112.