home *** CD-ROM | disk | FTP | other *** search
- ;--------------------------------------------------------------------
- ; Author : Kevin Dahl :
- ; Last Revised : June 7, 1986 :
- ; :
- ; FILENAME - V24.ENH :
- ; :
- ; WRITEST :
- ; This routine displays any string to the display screen :
- ; starting at the place where the cursor is positioned. :
- ; This routine will also position the cursor after the last :
- ; character that is displayed to the screen. :
- ; ENTRY :
- ; [bp+6] = Length of string :
- ; [bp+7] = Ch[1] of string to be displayed on the screen. :
- ; :
- ; EXIT :
- ; Nothing is returned :
- ;--------------------------------------------------------------------
- writest proc near
- push ds
- push bp ; save stack
- mov bp,sp
- mov ah,0fh ; get current video mode
- int 10h ; using BIOS services
- xor dx,dx
- mov dl,ah ; save number columns per line
- cmp al,7 ; check for monochrome monitor
- je v92
- cmp al,3 ; check if text modes
- ja v96 ; graphics mode - no write
- mov cx,7 ; set for 40 col text modes
- cmp dl,80 ; check for num of cols
- jb v91 ; 40 cols if jmp
- inc cx ; if get here then 80 cols
- v91:
- xor ax,ax ; zero out ax
- mov al,bh ; active display page for CGA
- push bx ; save page #
- shl ax,cl ; calc address for display page
- mov cx,0B800h ; address for CGA
- add ax,cx ; calc address to display string
- jmp v93
- v92:
- mov ax,0B000h ; monochrome monitor address
- v93:
- mov es,ax ; video address into es
-
- push dx ; save #cols/line
- mov ah,3 ; get cursor location info
- int 10h ; use BIOS services
- xor ax,ax ; zero out ax register
- xor bx,bx ; zero out bx register
- mov al,dh ; row coordinate
- mov bl,dl ; col coordinate
-
- pop dx ; get #cols/line
- mul dx ; row * number of columns
- add ax,bx ; row * # cols + col offset
- shl ax,1 ; row * #cols + col offset * 2
- mov di,ax ; offset in display scrn for string
-
- mov cx,[bp+6] ; length of string
- xor ch,ch ; remove first character from ch
- cmp cx,1
- jb v96 ; no string to display
- mov ax,bp ; address of base page into ax
- add ax,7 ; calc offset of string in stack
- mov si,ax ; move offset of string into si
- mov ax,ss
- mov ds,ax ; stack segment into data segment
- mov bl,[bp+262] ; attribute byte into bl
- mov dx,03DAh ; status port
- cld ; clear direction flag
- cli ; clear interrupts
- v94:
- in al,dx ; get status
- test al,1 ; is it low?
- jnz v94 ; wait until it is
- v95:
- in al,dx ; get status
- test al,1 ; is it high?
- jz v95 ; wait until it is
- movsb ; display character
- inc di ; skip attribute byte
- loop v94 ; repeat until all characters displayed
- sti ; turn interrupts back on
-
- mov ah,15 ; get video mode information
- int 10h ; using BIOS services
- mov bl,ah ; move #cols/line
- push bx ; save cols/line & page#
- mov ah,3 ; get the current x,y coordinates
- int 10h ; of the cursor using BIOS serives
- xor ax,ax ; zero out the ax register
- mov al,dl ; col# into al
- add al,[bp+6] ; add string length
- pop bx ; get # cols/line
- push dx ; save row, col information
- div bl ; length(st) div #cols/line
- pop dx ; get row, col information
- add dh,al ; calc new row position
- mov dl,ah ; new col position
- mov ah,2 ; use BIOS services to set
- int 10h ; new cursor position
- v96:
- mov sp,bp ; restore stack
- pop bp ; restore base pointer
- pop ds ; restore data segment
- ret 256 ; remove parameters and return
- writest endp
-