home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol11n11.zip / LABNOT.ZIP / MONOPRNT.ASM < prev    next >
Assembly Source File  |  1992-02-24  |  2KB  |  71 lines

  1. ;MonoPrnt.ASM
  2. ;Copyright (c) 1992 Jay Munro
  3. ;First Published in PC Magazine June 16,1992
  4.  
  5. ;Routine to access 2nd monochrome monitor from Visual Basic
  6.  
  7. ;syntax:
  8. ;Call MonoPrint(Byval Text$, BYVAL Row%, BYVAL Col%, Byval Attr%)
  9.  
  10. .286
  11. .Model Medium   
  12. Public MonoPrint
  13. Include Labnotes.Inc
  14. Extrn __B000h:ABS               ;absolute selector
  15. Extrn LStrLen:Proc              ;string length API routine
  16.  
  17. .Code
  18.     Text$   Equ  [BP+12]        ;incoming parameters
  19.     Row     Equ  [BP+10]
  20.     Col     Equ  [BP+8]
  21.     Attr    Equ  [BP+6]
  22.     
  23. MonoPrint Proc Far 
  24.    WinProlog
  25.    SaveESDISI
  26.    Lds  SI,Text$                ;get segment/address to string
  27.    Push DS                      ;push segment and address
  28.    Push SI
  29.    Call LStrLen                 ;get the length
  30.    Mov  CX,AX                   ;get length into CX
  31.    Jcxz Exit                    ;sorry, no zero len strings
  32.    Mov  AX,__B000h              ;get exported selector
  33.    Mov  ES,AX
  34.    Mov  DI,Row                  ;get row
  35.    Or   DI,DI                   ;skip dec if they used 0
  36.    Jz   @F
  37.    Dec  DI                      ;make 1 base to 0 base
  38. @@:
  39.    Mov  DX,Col                  ;and column
  40.    Or   DX,DX                   ;    1 base to 0 base
  41.    Jz   @F                      ;skip if they used 0
  42.    Dec  DX                      ;
  43. @@:
  44.    Mov  BX,DI                   ;make a copy of rows
  45.    Shl  DI,6                    ;multiply rows times 64
  46.    Shl  BX,4                    ;multiply copy rows by 16
  47.    Add  DI,BX                   ;add the two together to get 80
  48.    Add  DI,DX                   ;and add columns in
  49.    Shl  DI,1                    ;and double it for attribute
  50.    Or   DI, DI                  ;if zero, the force row 3
  51.    Jnz  @F
  52.    Mov  DI,480
  53. @@:
  54.    Mov  AH,Byte Ptr Attr        ;attribute color
  55.    Or   AH,AH
  56.    Jnz  WriteLoop
  57.    Mov  AH,7                    ;force a 7 attribute if zero comes in
  58.  
  59. WriteLoop:
  60.    LodSb                        ;read a byte
  61.    StoSw                        ;store a word
  62.    Loop WriteLoop
  63.  
  64. Exit:
  65.    RestESDISI
  66.    WinEpilog
  67.    Ret  10
  68. MonoPrint EndP
  69.  
  70. End
  71.