home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TUR6_101.ZIP / V14.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-06-07  |  4.9 KB  |  80 lines

  1. ;--------------------------------------------------------------------
  2. ; Author       : Kevin Dahl                                         :
  3. ; Last Revised : June 7, 1986                                       :
  4. ;                                                                   :
  5. ; FILENAME - V14.ENH                                                :
  6. ;                                                                   :
  7. ; PUTSCRN                                                           :
  8. ;        Read the character and its attribute byte into the         :
  9. ;        character buffer passed.                                   :
  10. ; ENTRY                                                             :
  11. ;        [bp+6]  = Segment of character array parameter             :
  12. ;        [bp+8]  = Starting address within segment of the character :
  13. ;                  array parameter.                                 :
  14. ;        [bp+10] = Number of characters to display to the screen.   :
  15. ;        [bp+12] = The row of the first character to display.       :
  16. ;        [bp+14] = The column of the first character to display.    :
  17. ;                                                                   :
  18. ; EXIT                                                              :
  19. ;        Nothing is return.                                         :
  20. ;--------------------------------------------------------------------
  21. putscrn       proc      near
  22.               push      ds
  23.               push      bp                       ; save stack
  24.               mov       bp,sp
  25.               mov       ah,0fh                   ; get current video mode
  26.               int       10h                      ; using BIOS services
  27.               xor       dx,dx                    ; zero out dx register
  28.               mov       dl,ah                    ; save number columns per line
  29.               cmp       al,7                     ; check for monochrome monitor
  30.               je        v49
  31.               cmp       al,3                     ; check if text modes
  32.               ja        v53                      ; graphics mode - no write
  33.               mov       cx,7                     ; set for 40 col text modes
  34.               cmp       dl,80                    ; check for num of cols
  35.               jb        v48                      ; 40 cols if jmp
  36.               inc       cx                       ; if get here then 80 cols
  37. v48:
  38.               xor       ax,ax                    ; zero out ax
  39.               mov       al,bh                    ; active display page for CGA
  40.               shl       ax,cl                    ; calc address for display page
  41.               mov       cx,0B800h                ; address for CGA
  42.               add       ax,cx                    ; calc starting address
  43.               jmp       v50
  44. v49:
  45.               mov       ax,0B000h                ; monochrome monitor address
  46. v50:
  47.               mov       es,ax                    ; video address into es
  48.               lds       si,[bp+6]                ; point ds to char array
  49.               mov       ax,[bp+12]               ; row coordinate
  50.               mov       bx,[bp+14]               ; col coordinate
  51.               dec       ax                       ; (row - 1)
  52.               mul       dx                       ; (row - 1) * number of columns
  53.               add       ax,bx                    ; (row - 1) * # cols + col offset
  54.               dec       ax                       ; (row - 1) * # cols + col offset - 1
  55.               shl       ax,1                     ; ((row-1)* #cols + col offset - 1)*2
  56.               mov       di,ax                    ; offset for string
  57.               mov       cx,[bp+10]               ; number of character to display
  58.               cmp       cx,1
  59.               jb        v53                      ; no characters to display
  60.               mov       dx,03DAh                 ; status port
  61.               cld                                ; clear direction flag
  62.               cli                                ; clear interrupts
  63. v51:
  64.               in        al,dx                    ; get status
  65.               test      al,1                     ; is it low?
  66.               jnz       v51                      ; wait until it is
  67. v52:
  68.               in        al,dx                    ; get status
  69.               test      al,1                     ; is it high?
  70.               jz        v52                      ; wait until it is
  71.               movsw                              ; put char & attribute byte
  72.               loop      v51                      ; repeat until done
  73.               sti                                ; turn interrupts back on
  74. v53:
  75.               mov       sp,bp                    ; restore stack
  76.               pop       bp                       ; restore base pointer
  77.               pop       ds                       ; restore data segment
  78.               ret       10                       ; remove parameters and return
  79. putscrn       endp
  80.