home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l320 / 2.img / EXAMPLES / DISPTTYF.S < prev    next >
Encoding:
Text File  |  1989-08-23  |  4.7 KB  |  128 lines

  1.  
  2.         NAME DISPTTYF.S
  3.         .387
  4.         assume  cs:codeseg
  5.         assume  ds:dataseg
  6. codeseg segment dword er use32 public 'code'
  7. ; Purpose: Demonstrate interface between NDP Fortran and
  8. ; assembly language calls to system services (DOS and ROM BIOS)
  9. ; Assembly language equivalent of using int386 subroutine
  10. ; Copyright (C) MicroWay, Inc., 1989
  11.  
  12. dataseg segment dword rw use32 public 'data'
  13.         current_attr    db ?
  14.         active_page     db ?
  15.         row             db ?
  16.         col             db ?
  17.         maxcol          db ?
  18. dataseg ends
  19.  
  20. VIDEO_IO equ 10h
  21.  
  22. ; ************************************************************
  23. ; _display_tty_
  24. ; This function displays a string of characters on the screen
  25. ; with a given attribute, and advances the cursor. Since there
  26. ; is no single ROM BIOS video service that does both, it
  27. ; combines the functionality of two of them:
  28. ;       Service 9, Write Character and Attribute
  29. ;       Service 2, Set Cursor Position
  30. ; The four parameters are:
  31. ;       Pointer to the attribute(s) to be added
  32. ;       Pointer to the attribute(s) to be deleted
  33. ;       Pointer to a string of characters
  34. ;       Value of (not pointer to) length of string
  35. ; The coding of the attribute byte:
  36. ;            Bit
  37. ;       7 6 5 4 3 2 1 0
  38. ;       1 . . . . . . .    Blinking of foreground character
  39. ;       . 1 . . . . . .    Red component of background color
  40. ;       . . 1 . . . . .    Green component of background color
  41. ;       . . . 1 . . . .    Blue component of background color
  42. ;       . . . . 1 . . .    Intensity of foreground color
  43. ;       . . . . . 1 . .    Red component of foreground color
  44. ;       . . . . . . 1 .    Green component of foreground color
  45. ;       . . . . . . . 1    Blue component of foreground color
  46. ;
  47. ; The current attribute byte is ANDed with the attribute(s)
  48. ; to be removed and OR'd with the new attribute(s) to be added.
  49.  
  50.         align   4
  51. _display_tty_  proc     near
  52. public _display_tty_
  53. PARM1 = 4
  54. IRP reg,<ebp,ebx,ecx,edx,esi,edi>
  55.         push    reg
  56.         PARM1 = PARM1 + 4
  57. ENDM
  58.         mov     ebp,esp
  59.  
  60. PARM2 equ PARM1+4
  61. PARM3 equ PARM2+4
  62. PARM4 equ PARM3+4
  63.  
  64. ADD_ATTR equ [ebp+PARM1]   ; integer - new attribute(s) to be added
  65. DEL_ATTR equ [ebp+PARM2]   ; integer - attribute(s) to be removed
  66. PSTRING equ [ebp+PARM3]    ; pointer to string of characters
  67. STRINGLEN equ [ebp+PARM4]  ; length of string
  68.  
  69.         mov     ah,15           ; get current video mode
  70.         int     VIDEO_IO
  71.         mov     active_page,bh
  72.         mov     maxcol,ah
  73.  
  74.         mov     ah,8            ; get current attribute
  75.         int     VIDEO_IO
  76.         mov     current_attr,ah
  77.  
  78.         mov     ah,3            ; read cursor position
  79.         mov     bh,active_page
  80.         int     VIDEO_IO
  81.         mov     row,dh
  82.         mov     col,dl
  83.                                 ; put new attribute value into bl
  84.         mov     eax,ADD_ATTR    ; ptr to new attribute(s) -> eax
  85.         mov     eax,[eax]       ; bit pattern to be added -> eax
  86.         mov     edx,DEL_ATTR ; ptr to delete attribute(s) -> edx
  87.         mov     edx,[edx]       ; bit pattern to be deleted -> edx
  88.         mov     bl,current_attr
  89.         and     bl,dl           ; remove unwanted attribute(s)
  90.         or      bl,al           ; add new attribute(s)
  91.         mov     esi,PSTRING     ; esi points to string
  92.         mov     edi,esi
  93.         add     edi,STRINGLEN   ; edi points to end of string
  94.         mov     ecx,1           ; only one char, attr at a time
  95. next_char:
  96.         lodsb
  97.         or      al,al           ; get the next character
  98.         jz      done            ; if 0, we are done
  99.         mov     ah,9            ; output char, attr
  100.         int     VIDEO_IO
  101.         mov     dl,col          ; current column to dl
  102.         inc     dl              ; point at next column
  103.         mov     col,dl          ; save the new value
  104.         cmp     dl,maxcol       ; do we need to wrap around?
  105.         jb      no_wrap         ; if not, don't reinit col
  106.         mov     col,0           ; else reinit col
  107.         inc     row             ; go to next row
  108.         cmp     row,25          ; are we at last row?
  109.         jb      no_wrap         ; if not, don't reinit row
  110.         mov     row,0           ; else, reinit row
  111. no_wrap:
  112.         mov     ah,2            ; advance cursor
  113.         mov     dh,row
  114.         mov     dl,col
  115.         int     VIDEO_IO
  116.         cmp     esi,edi         ; have we reached end of string?
  117.         je      done            ; if yes, we are done
  118.         jmp     next_char       ; otherwise, get next character
  119. done:
  120. IRP reg,<edi,esi,edx,ecx,ebx,ebp>
  121.         pop     reg
  122. ENDM
  123.         ret
  124. _display_tty_ endp
  125. codeseg ends
  126.         end
  127.  
  128.