home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c222 / 1.ddi / SOURCE / IBMLIB / PR_DRIVE.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-09-25  |  3.8 KB  |  195 lines

  1. ;
  2. ;  pr_drive.asm
  3. ;
  4. ;  Purpose: Printer primitives.
  5. ;
  6. ;  Blackstar C Function Libarary
  7. ;  (c) Copyright 1985,1989 Sterling Castle Software
  8. ;
  9.  
  10.     include model
  11.     include blackstr.mac
  12.  
  13.     extrnf  pr_prtscr       ; print screen routine
  14.  
  15.  
  16.     dseg    'DATA'
  17.  
  18.     bwstat  equ     03bah   ; B/W video status port
  19.     busyf   equ     'B'     ; busy flag - already printing screen
  20.     msdosf  equ     21h     ; interrupt for msdos function
  21.     prntcom equ     0       ; BIOS command for print character
  22.     prntint equ     17h     ; printer interrupt vector
  23.  
  24.     ; local stack for printer interrupt
  25.     ;
  26.     sstk    db      'Start of stack'; start of stack
  27.     stck_m    db    256 dup(?)
  28.     pstack  equ     $-2             ; start it here
  29.     estk    db      'End of stack'  ; end of stack
  30.  
  31.     status  db      00              ;busy/idle screen print flag
  32.  
  33.     enddseg
  34.  
  35.  
  36.     cseg    pr_prtsc_
  37.  
  38.  
  39. ;-----------------
  40. ;       pr_prtsc_               printer interrupt service routine
  41. ;-----------------
  42. ;                               Usage: pr_prtsc_();
  43. ;
  44. ;                               int pr_prtsc_(void);
  45.  
  46.     public pr_prtsc_
  47.  
  48. pr_prtsc_ proc
  49.     ifdef   Large_data
  50.     mov     ax,seg dgroup
  51.     mov     ds,ax
  52.     endif
  53.  
  54.     mov     al,byte ptr status
  55.     cmp     al,busyf        ;already printing screen?
  56.     je      int_x
  57.  
  58. prtsc1: mov     byte ptr status, busyf ;make it busy
  59.     push    eax
  60.     push    ebx
  61.     push    ecx
  62.  
  63.     ; set up our own stack
  64.  
  65.     mov     bx,ss           ;save old stack on stack
  66.     mov     ecx,esp
  67.  
  68.     ifdef   Large_data
  69.     mov     ax,seg dgroup   ;stack is in this seg
  70.     else
  71.     mov     ax,ds
  72.     endif
  73.  
  74.     cli
  75.     ifndef  asm_386
  76.     mov     ss,ax           ;set stack segment to here
  77.     endif
  78.     mov     esp,offset dgroup:pstack
  79.     sti
  80.  
  81.     push    ebx
  82.     push    ecx
  83.     push    edx
  84.     push    edi
  85.     push    esi
  86.     push    ebp
  87.     push    ds
  88.     push    es
  89.  
  90.     ifdef   Large_data
  91.     mov     ax,seg dgroup
  92.     else
  93.     mov     ax,ds
  94.     endif
  95.  
  96.     mov     ds,ax           ;point ds to dgroup
  97.     mov     es,ax           ;and es
  98.     call    pr_prtscr
  99.  
  100.     ; exit from print screen interrupt
  101.  
  102. int_exit:
  103.     pop     es
  104.     pop     ds
  105.     pop     ebp
  106.     pop     esi
  107.     pop     edi
  108.     pop     edx
  109.     pop     ecx
  110.     pop     ebx
  111.  
  112.     ; restore beginning stack
  113.  
  114.     cli
  115.     mov     esp,ecx
  116.     ifndef  asm_386
  117.     mov     ss,bx
  118.     endif
  119.     sti
  120.  
  121.     pop     ecx
  122.     pop     ebx
  123.     pop     eax
  124.     mov     byte ptr status,0    ;no more busy
  125.  
  126. int_x:  iret
  127. pr_prtsc_ endp
  128.  
  129.  
  130. ;------------------
  131. ;       pr_putc_                print character to standard printer device
  132. ;------------------
  133. ;                               Usage: pr_putc_(c);
  134. ;
  135. ;                               int pr_putc_(char c);
  136. ;
  137. ;       Returns FALSE if character was not printed, TRUE (1) if it was
  138.  
  139.     public  pr_putc_
  140.  
  141. pr_putc_ proc
  142.     parms<<c,byte>>
  143.     prolog
  144.  
  145.     ifdef   Large_data
  146.     mov     ax,seg dgroup
  147.     mov     ds,ax
  148.     endif
  149.  
  150.     mov     al,c            ;get byte to print to dl
  151.     mov     ah,prntcom      ;print command
  152.     mov     edx,0           ;use printer 0
  153.     int     prntint         ;do dos funtion interrupt
  154.     cmp     al,1            ;was it printed
  155.     mov     eax,0
  156.     je      printc1         ;if not, return FALSE
  157.     mov     eax,1           ;return TRUE in eax
  158.  
  159. printc1:
  160.     epilog
  161. pr_putc_ endp
  162.  
  163.  
  164. ;------------------
  165. ;       pr_stat_                get printer status
  166. ;------------------
  167. ;                               Usage: pr_stat_(port, command);
  168. ;
  169. ;                               int pr_stat_(int port, int command);
  170. ;
  171.  
  172.     public  pr_stat_
  173.  
  174. pr_stat_ proc
  175.     parm386<<number,dword>,<command,byte>>
  176.     parm86<<number,word>,<command,byte>>
  177.     prolog
  178.  
  179.     mov     edx,number      ;get printer number to edx
  180.     mov     ah,command
  181.     int     prntint         ;do printer interrupt
  182.     mov     al,ah           ;return in al
  183.     mov     ah,0
  184.  
  185.     ifdef    asm_386
  186.     movsx    eax,ax
  187.     endif
  188.  
  189.     epilog
  190. pr_stat_ endp
  191.  
  192.     endcseg    pr_prtsc_
  193.     end
  194.  
  195.