150 likes | 225 Views
Lecture # 12. Printer Interface. Printer Interface. ACK. PIC. INT. IRQ7. Printer. Interrupt Driven Printer I/O. char buf [1024]; int i = 0; void interrupt (*oldint)( ); void interrupt newint (); void main (void) { outport(( *lpt), inport( *lpt) | 4);
E N D
Printer Interface Printer Interface ACK PIC INT IRQ7 Printer
Interrupt Driven Printer I/O char buf [1024]; int i = 0; void interrupt (*oldint)( ); void interrupt newint (); void main (void) { outport(( *lpt), inport( *lpt) | 4); outport(( *lpt), inport( *lpt) | 0x10); oldint =getvect (0x0F); setvect (0x0F, newint); outport(0x21, inport( 0x21) | 0x80); keep(0,1000); }
void interrupt newint ( ) { outport( *lpt, Buf[ i]); outport(( *lpt)+2, inport(( *lpt)+2) &0xFE); outport(( *lpt)+2, inport(( *lpt)+2) | 1); i++; if( i== 1024) { outport(0x21, inport(0x21)&0x7F); setvect(0x0F,oldint); freemem(_psp); } }
#include <stdio.h>#include <dos.h>#include <bios.h>#include <conio.h>#include <stdlib.h>void interrupt (*oldint)();void interrupt newint();unsigned int far * lpt = (unsigned int far *)0x00400008;char st[80]= "this is a test print string !!!!!!!!!!!";int i ;void main (){ oldint = getvect(0x08); setvect(0x08,newint); keep(0,1000);}
void interrupt newint(){ if ((( inport((*lpt) +1)) & 0x80) == 0x80) { outport (*lpt,st[i++]); outport ((*lpt)+2, inport((*lpt)+2) & 0xfe); outport ((*lpt)+2, inport((*lpt)+2) | 1); } if (i==32) { setvect (0x08,oldint); freemem(_psp); } (*oldint) ();}
P0 2 15 Q3 P1 3 13 Q4 P2 4 12 Q5 P3 5 10 Q6 P4 6 11 Q7 Q3 15 2 P0 Q4 13 3 P1 Q5 12 4 P2 Q6 10 5 P3 Q7 11 6 P4
D4 D3 D2 D1 D0 Sender Sender sends LOW Nibble and D4 = 0 received as BUSY = 1 Receiver BUSY ACK PE SLC ER E7 E6 E5 E4 E3
BUSY ACK PE SLC ER Sender Receiver send back LOW Nibble and D4=0 received as BUSY = 1 by Sender Receiver D4 D3 D2 D1 D0
D4 D3 D2 D1 D0 Sender Sender sends Hi Nibble and turns D4 = 1 received as BUSY = 0 by Receiver Receiver BUSY ACK PE SLC ER
BUSY ACK PE SLC ER Sender Receiver send back Hi Nibble and turns D4 = 1 received as BUSY = 0 by Sender Receiver D4 D3 D2 D1 D0
-d 40:080040:0000 78 03 00 00 00 00 0D 02 x.......0040:0010 67 44 01 80 02 1C 00 00-00 00 36 00 36 00 74 14 gD........6.6.t.0040:0020 78 2D 74 14 0D 1C 64 20-20 39 34 05 30 0B 3A 27 x-t...d 94.0.:'0040:0030 30 0B 38 09 0D 1C 75 16-6D 32 70 19 2E 34 00 00 0.8...u.m2p..4..0040:0040 00 00 FF 50 01 00 00 A0-70 03 50 00 00 10 00 00 ...P....p.P.....0040:0050 00 18 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................0040:0060 0E 0D 00 D4 03 29 20 CC-FF 00 20 04 6B E2 0B 00 .....) ... .k...0040:0070 00 00 34 12 00 01 08 03-14 14 14 14 01 01 01 01 ..4.............0040:0080 1E 00 3E 00 18 10 00 60 ..>....`-q
C:\>debug-o 378 0A-i 379D0-o 378 19-i 37948 Sending byte 9A C:\>debug-i 379D7-o 378 0A-i 3794F-o 378 19