home *** CD-ROM | disk | FTP | other *** search
-
- NAME DISPTTYC.S
- .387
- assume cs:codeseg
- assume ds:dataseg
- codeseg segment dword er use32 public 'code'
- ; Purpose: Demonstrate interface between NDP C and
- ; assembly language calls to system services (DOS and ROM BIOS)
- ; Assembly language equivalent of using int386() function
- ; Copyright (C) MicroWay, Inc., 1989
-
- dataseg segment dword rw use32 public 'data'
- current_attr db ?
- active_page db ?
- row db ?
- col db ?
- maxcol db ?
- dataseg ends
-
- VIDEO_IO equ 10h
-
- ; ************************************************************
- ; _display_tty
- ; This function displays a string of characters on the screen
- ; with a given attribute, and advances the cursor. Since there
- ; is no single ROM BIOS video service that does both, it
- ; combines the functionality of two of them:
- ; Service 9, Write Character and Attribute
- ; Service 2, Set Cursor Position
- ; The three parameters are:
- ; The attribute(s) to be added
- ; The attribute(s) to be deleted
- ; Pointer to a null-terminated string of characters
- ; The coding of the attribute byte:
- ; Bit
- ; 7 6 5 4 3 2 1 0
- ; 1 . . . . . . . Blinking of foreground character
- ; . 1 . . . . . . Red component of background color
- ; . . 1 . . . . . Green component of background color
- ; . . . 1 . . . . Blue component of background color
- ; . . . . 1 . . . Intensity of foreground color
- ; . . . . . 1 . . Red component of foreground color
- ; . . . . . . 1 . Green component of foreground color
- ; . . . . . . . 1 Blue component of foreground color
- ;
- ; The current attribute byte is ANDed with the attribute(s)
- ; to be removed and OR'd with the new attribute(s) to be added.
-
-
- align 4
- _display_tty proc near
- public _display_tty
- PARM1 = 4
- IRP reg,<ebp,ebx,ecx,edx,esi>
- push reg
- PARM1 = PARM1 + 4
- ENDM
- mov ebp,esp
-
- PARM2 equ PARM1+4
- PARM3 equ PARM2+4
-
- ADD_ATTR equ [esp+PARM1] ; integer - new attribute(s) to be added
- DEL_ATTR equ [esp+PARM2] ; integer - attribute(s) to be removed
- PSTRING equ [esp+PARM3] ; pointer to null-terminated string
-
- mov ah,15 ; get current video mode
- int VIDEO_IO
- mov active_page, bh
- mov maxcol,ah
-
- mov ah,8 ; get current attribute
- int VIDEO_IO
- mov current_attr,ah
-
- mov ah,3 ; read cursor position
- mov bh,active_page;
- int VIDEO_IO
- mov row,dh
- mov col,dl
-
- ; put new attribute value into bl
- mov eax,ADD_ATTR ; bit pattern to be added -> eax
- mov edx,DEL_ATTR ; bit pattern to be deleted -> edx
- mov bl,current_attr
- and bl,dl ; remove unwanted attribute(s)
- or bl,al ; add new attribute(s)
-
- mov esi,PSTRING ; esi points to string
- mov ecx,1 ; only one char, attr at a time
- next_char:
- lodsb ; get the next character
- or al,al ; if 0, we are done
- jz done
- mov ah,9 ; output char, attr
- int VIDEO_IO
- mov dl,col ; current column -> dl
- inc dl ; point at next column
- mov col,dl ; save the new value
- cmp dl,maxcol ; do we need to wrap around?
- jb no_wrap ; if not, don't reinit col
- mov col,0 ; else reinit col
- inc row ; go to next row
- cmp row,25 ; are we at last row?
- jb no_wrap ; if not, don't reinit row
- mov row,0 ; else, reinit row
- no_wrap:
- mov ah,2 ; advance cursor
- mov dh,row
- mov dl,col
- int VIDEO_IO
- jmp next_char
- done:
- IRP reg,<esi,edx,ecx,ebx,ebp>
- pop reg
- ENDM
- ret
- _display_tty endp
- codeseg ends
- end
-
-